JavaSE series code 38: Specify the size of the label object

Jar (Java Archive) is a standard compressed file with special internal structure. You can use winrar and other compression software to open jar files.
Jar files can contain anything, such as class files, image files or other data to use, program source code, and so on. The internal structure of jar is like the standard directory setting. Each file has a location and directory, just like the directory structure in the disk.
Using jar.exe, you can compress and package the bytecode files of some classes into a “. Jar” file. For example: jar CF m.jar * — package all files in the current directory into mylib.jar.

import java.awt.*; 
public class Javase_38
{
  static Frame frm=new Frame("标签类窗口");
  static Label lab=new Label();    //创建标签对象
  public static void main(String[] args)
  {
    frm.setLayout(null);    //取消页面设置
    frm.setSize(300,200); 
    frm.setBackground(Color.pink);
    lab.setText("我是一个标签"); 
    lab.setAlignment(Label.CENTER); 
    lab.setBackground(Color.yellow); 
    lab.setForeground(Color.red); 
    lab.setLocation(120,90); 
    lab.setSize(130,30); 
    Font fnt=new Font("Serief",Font.BOLD+Font.ITALIC,20);
    lab.setFont(fnt); 
    frm.add(lab); 
    frm.setVisible(true);
  }
}

Published 52 original articles · Like 162 · Visitors 10,000+

Guess you like

Origin blog.csdn.net/blog_programb/article/details/105393975