public class JF extends JFrame implements ActionListener {
JDesktopPane jdp;
JButton but;
public JF() {
super("Quistis");
but = new JButton("添加");
jdp = new JDesktopPane();
this.getContentPane().add(but, BorderLayout.NORTH);
this.getContentPane().add(jdp);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
but.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
JInternalFrame ff = new JInternalFrame();//JInternalFrame==JFrame
ff.setMaximizable(true);//设子窗体有最大化按钮!!
ff.setClosable(true);//设子窗体有关闭按钮!!
ff.setVisible(true);
ff.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
ff.setResizable(true);
ff.setSize(200, 200);
jdp.add(ff);
}
public static void main(String ars[]) {
JFrame.setDefaultLookAndFeelDecorated(true);
JF f = new JF();
f.setSize(500, 500);
f.validate();
f.setVisible(true);