package shi1;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class box extends JFrame{
public box() {
this.setBounds(100,300,400,500);
this.setTitle("周开伟");
JButton jb1=new JButton("0");
JButton jb2=new JButton("1");
JButton jb3=new JButton("2");
JButton jb4=new JButton("3");
JButton jb5=new JButton("4");
JButton jb6=new JButton("5");
JButton jb7=new JButton("6");
JButton jb8=new JButton("7");
JButton jb9=new JButton("8");
JButton jb10=new JButton("9");
JButton jb11=new JButton("10");
JButton jb12=new JButton("11");
JButton jb13=new JButton("12");
JButton jb14=new JButton("13");
JButton jb15=new JButton("14");
JButton jb16=new JButton("15");
this.setLayout(new GridLayout(4,4));
this.add(jb1);
this.add(jb2);
this.add(jb3);
this.add(jb4);
this.add(jb5);
this.add(jb6);
this.add(jb7);
this.add(jb8);
this.add(jb9);
this.add(jb10);
this.add(jb11);
this.add(jb12);
this.add(jb13);
this.add(jb14);
this.add(jb15);
this.add(jb16);
}
}
package shi1;
public class text {
public static void main(String[] args) {
box s=new box();
s.setVisible(true);
}
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/3b5d2685308b0e7163d1eb05d6b56a4a.png)
package shi1;
import java.awt.Font;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class fad extends JFrame{
public fad() {
setLayout(new GridLayout(4,4));
setFont(new Font("Times New Roman", Font.BOLD,24));
for (int i = 0; i <4; i++) {
for (int j = 0; j <4; j++) {
int k=i*4+j;
add(new JButton(""+k));
}
}
this.setSize(450,300);
this.setVisible(true);
}
}
package shi1;
public class text {
public static void main(String[] args) {
fad s=new fad();
s.setVisible(true);
}
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/ad4e04b54888dc3750ec75fc0f040952.png)
package shi1;
import java.awt.FlowLayout;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
public class qirijier extends JFrame{
public qirijier() {
this.setBounds(300, 200, 500, 600);
this.setTitle("周开伟的窗口");
ImageIcon jf=new ImageIcon("C:\\Users\\Lenovo\\Pictures\\opo.jpg");
this.setIconImage(jf.getImage());
JButton jb1=new JButton("登录");
JButton jb2=new JButton("注册");
JButton jb3=new JButton("注销");
JButton jb4=new JButton("登录");
JButton jb5=new JButton("注册");
JButton jb6=new JButton("注销");
JButton jb7=new JButton("登录");
JButton jb8=new JButton("注册");
JButton jb9=new JButton("注销");
this.setLayout(new FlowLayout(FlowLayout.LEFT,40,40));
this.add(jb1);
this.add(jb2);
this.add(jb3);
this.add(jb4);
this.add(jb5);
this.add(jb6);
this.add(jb7);
this.add(jb8);
this.add(jb9);
}
}
package shi1;
public class test {
public static void main(String[] args) {
qirijier jf=new qirijier();
jf.setVisible(true);
}
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/f0c1b526c1478e4d033453d94a86233e.png)
package shi1;
import java.awt.FlowLayout;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
public class GridExample extends JFrame {
public GridExample() {
this.setBounds(300, 200, 500, 600);
this.setTitle("周开伟的窗口");
ImageIcon jf=new ImageIcon("C:\\Users\\Lenovo\\Pictures\\opo.jpg");
this.setIconImage(jf.getImage());
JButton jb1=new JButton("登录");
JButton jb2=new JButton("注册");
JButton jb3=new JButton("注销");
JButton jb4=new JButton("登录");
JButton jb5=new JButton("注册");
JButton jb6=new JButton("注销");
JButton jb7=new JButton("登录");
JButton jb8=new JButton("注册");
JButton jb9=new JButton("注销");
this.setLayout(new GridLayout(3, 4));
this.add(jb1);
this.add(jb2);
this.add(jb3);
this.add(jb4);
this.add(jb5);
this.add(jb6);
this.add(jb7);
this.add(jb8);
this.add(jb9);
}
public static void main(String[]args) {
GridExample s=new GridExample();
s.setVisible(true);
}
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/ee65e64ed5f8555c8e9df9b5d703b105.png)
package shi1;
import java.awt.FlowLayout;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
public class SomeExample extends JFrame{
public SomeExample() {
this.setBounds(100,100,500,400);
this.setTitle("用户登录");
this.setLayout(null);
JLabel jb=new JLabel("账号:");
JLabel jbj=new JLabel("密码:");
jb.setBounds(20,55,50,20);
jbj.setBounds(20,95,50,20);
this.add(jb);
this.add(jbj);
JTextField jf1=new JTextField(10);
JTextField jf2=new JTextField(10);
jf1.setBounds(120,50,200,30);
jf2.setBounds(120,90,200,30);
this.add(jf2);
this.add(jf1);
JButton ll=new JButton("登录");
JButton pp=new JButton("注册");
ll.setBounds(120,130,70,25);
pp.setBounds(250,130,70,25);
this.add(ll);
this.add(pp);
}
public static void main (String[]args) {
SomeExample s=new SomeExample();
s.setVisible(true);
}
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/6816d83d99caf83aba51dd1beeaa4db7.png)