AWT-Frame
作者:互联网
2、AWT
2.1、AWT
2.2组件和容器
package gui.awt;
import java.awt.*;
public class TestFrame {
public static void main(String[] args) {
//设置窗口名称
Frame frame = new Frame("第一个Frame窗口");
//设置窗口大小
frame.setSize(1000,1000);
//设置位置
frame.setLocation(200,200);
//设置窗口背景颜色
frame.setBackground(new Color(255, 255, 255));
//设置窗口可见性
frame.setVisible(true);
//设置为不可变大变小
frame.setResizable(false);
}
}
package gui.awt;
import java.awt.*;
public class TestFram01 {
public static void main(String[] args) {
MyFrame frame01 = new MyFrame("01",100,100,200,200,Color.blue);
MyFrame frame02 = new MyFrame("02",300,100,200,200,Color.yellow);
MyFrame frame03 = new MyFrame("03",100,300,200,200,Color.white);
MyFrame frame04 = new MyFrame("04",300,300,200,200,Color.green);
}
}
class MyFrame extends Frame {
public MyFrame(String tile,int x,int y,int w,int h,Color color){
setTitle(tile);
setBounds(x,y,w,h);
setBackground(color);
setVisible(true);
}
}
标签:200,Color,Frame,AWT,public,new,frame,MyFrame 来源: https://www.cnblogs.com/tangqiyao11/p/14606936.html