参考一下:import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;public class star extends JFrame implements ActionListener
{
JDesktopPane desk;
int count=1;
public star()
{
Container c=this.getContentPane();
c.setLayout(new BorderLayout());
Button b1=new Button("OK");
c.add(b1,BorderLayout.SOUTH);
desk=new JDesktopPane();
c.add(desk);
b1.addActionListener(this);
setSize(500,500);
show();
}
public void actionPerformed(ActionEvent e)
{
JInternalFrame j = new JInternalFrame();
j.setTitle(""+count++);
j.setLocation(10*count,10*count);
j.setSize(200,200);
j.setVisible(true);
Container c1=j.getContentPane();
JTextArea textArea = new JTextArea();
JButton b2 = new JButton("Internal Frame Button");
c1.add(textArea,BorderLayout.CENTER);
c1.add(b2,BorderLayout.SOUTH);
desk.add(j);
desk.setVisible(true);
try{
j.setSelected(true);
}catch(java.beans.PropertyVetoException w)
{
}
}
public static void main(String args[])
{
JFrame.setDefaultLookAndFeelDecorated(true);
star s=new star();
s.setTitle("star");
}
}
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;public class star extends JFrame implements ActionListener
{
JDesktopPane desk;
int count=1;
public star()
{
Container c=this.getContentPane();
c.setLayout(new BorderLayout());
Button b1=new Button("OK");
c.add(b1,BorderLayout.SOUTH);
desk=new JDesktopPane();
c.add(desk);
b1.addActionListener(this);
setSize(500,500);
show();
}
public void actionPerformed(ActionEvent e)
{
JInternalFrame j = new JInternalFrame();
j.setTitle(""+count++);
j.setLocation(10*count,10*count);
j.setSize(200,200);
j.setVisible(true);
Container c1=j.getContentPane();
JTextArea textArea = new JTextArea();
JButton b2 = new JButton("Internal Frame Button");
c1.add(textArea,BorderLayout.CENTER);
c1.add(b2,BorderLayout.SOUTH);
desk.add(j);
desk.setVisible(true);
try{
j.setSelected(true);
}catch(java.beans.PropertyVetoException w)
{
}
}
public static void main(String args[])
{
JFrame.setDefaultLookAndFeelDecorated(true);
star s=new star();
s.setTitle("star");
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货