package test;
import java.awt.*;
import javax.swing.*;
public class demo extends JFrame{
private JButton jb = null;
private JButton jb1 = null;
private JButton jb2 = null;
private JButton jb3 = null;
private JButton jb4 = null;
public static void main(String[] args){
demo demo1 = new demo();
}
//构造函数
public demo(){
jb = new JButton("点我");
jb1 = new JButton("东");
jb2 = new JButton("南");
jb3 = new JButton("西");
jb4 = new JButton("北");
this.add(jb);
this.add(jb1, BorderLayout.EAST);
this.add(jb2, BorderLayout.SOUTH);
this.add(jb3, BorderLayout.WEST);
this.add(jb4, BorderLayout.NORTH);
this.setTitle("你好啊!");
this.setLocation(100,200);
this.setSize(300,200) ;
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true) ;
}
}
运行结果: