import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Chap23_5 {
static JFrame frm=new JFrame("JInternalFrame");
static JButton btn=new JButton("New Frame");
static Container cp=frm.getContentPane();
static JDesktopPane jdp=new JDesktopPane();
public static void main(String args[])
{
cp.setLayout(new BorderLayout());
cp.add(btn,BorderLayout.SOUTH);
cp.add(jdp);
btn.addActionListener(new ActList());
frm.setSize(400, 300);
frm.setVisible(true);
}
static class ActList implements ActionListener
{
static int count=1;
public void actionPerformed(ActionEvent e)
{
JInternalFrame jif;
jif=new JInternalFrame("Frame " +(count++),true,true,true,true);
Container icp=jif.getContentPane();
JButton ibtn=new JButton("JInternalFrame Button");
icp.add(ibtn,BorderLayout.SOUTH);
jdp.add(jif);
jif.setSize(200, 150);
jif.setVisible(true);
}
}
}