public class JInternalFrame1 extends JFrame implements ActionListener{
JDesktopPane desktopPane; int count = 1;
public JInternalFrame1() { super("JInternalFrame1"); Container contentPane = this.getContentPane(); contentPane.setLayout(new BorderLayout());
JButton b = new JButton("Create New Internal Frames"); b.addActionListener(this);//当用户按下按钮时,将运行actionPerformed()中的程序 contentPane.add(b, BorderLayout.SOUTH); /*建立一个新的JDesktopPane并加入于contentPane中 */ desktopPane = new JDesktopPane(); contentPane.add(desktopPane);
public class JPanel1 { public JPanel1() { JFrame f = new JFrame("JPanelDemo"); Container contentPane = f.getContentPane(); contentPane.setLayout(new GridLayout(2,1)); JLabel[] label = new JLabel[5];