导入javax.swing.*
import javax.swing.*;
JFrame是这之中的一个类
使用“JFrame 对象名 = new JFrame(参数);”来创建JFrame类型对象
JFrame()的函数参数中填的是UI界面的标题,如:JFrame("这是一个UI界面")
对象名.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 这是UI界面的开关方式:直接点击右上角的叉即可关闭
或者可以 对象名.setDefaultCloseOperation(3);
对象名.setSize(长,宽); 这是设置界面长宽的
JFrame frame = new JFrame("MyUI");
frame.setBounds(0,0,1000,1000);//x坐标,y坐标,长,宽
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(null);//绝对布局,后面会将
frame.setVisible(true);//显示
//生成一个UI界面
JButton是这之中的一个类
使用“JButton 对象名 = new JButton(参数);”来创建JButton类型对象
对象作用:按钮
setBounds()的函数参数中:
四个参数:int x, int y, int width, int height