JavaSE系列代码35:加载java.awt类库里的所有类

Method overloading means that there can be multiple methods in a class with the same name, but the parameters of these methods must be different, that is, either the number of parameters is different or the type of parameters is different. The return type of the method and the name of the parameter do not participate in the comparison, that is, if the names of the two methods are the same, even if the types are different, the parameters must be different.

import java.awt.*;       //加载java.awt类库里的所有类
public class Javase_35
{
  static Frame frm=new Frame("这是个AWT程序");  //创建类静态框架并设置标题
  public static void main(String[] args)
  {
    Label lab=new Label("我是一个标签");     //创建一个标签对象lab
    frm.setSize(180,140);             //设置框架大小
    frm.setBackground(Color.yellow);   //设置框架背景颜色
    frm.setLocation(250,150);         //设置窗口的位置
    frm.add(lab);                    //将标签对象lab加入窗口中
    frm.setVisible(true);              //将窗口显示出来
  }
}
发布了52 篇原创文章 · 获赞 162 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/blog_programb/article/details/105393743