把容器加到容器上当然不行了,不过Java已经给你提供了其他的方法了。
可以用JDesktopPane和JInternalFrame来实现的。import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.util.EventListener;
import java.awt.event.ActionEvent;public class TestMenu extends JFrame implements ActionListener  
{
JMenuBar jmb;
JMenu jm;
JMenuItem jmi;
JJPane jdk;
Container con;
public TestMenu()
{
con = this.getContentPane();
jmb=new JMenuBar();
jm=new JMenu("打开新窗口");
jm.setMnemonic('a');
jmi=new JMenuItem("Open"+" "+"ALT A");
jmi.addActionListener(this);
jmi.setMnemonic('b');
jdk=new JJPane();


jm.add(jmi);
jm.addSeparator();
jmb.add(jm);
con.add(jdk);
this.setJMenuBar(jmb);
this.setSize(400,400);
this.setVisible(true);

}
public static void main(String args[])
{
new TestMenu();
} public void actionPerformed(ActionEvent e) {
if(e.getSource()==jmi)
{
JOpenFrame jo=new JOpenFrame();
jdk.add(jo);
}
}
}
//重写paintBorder方法,可以在JDesktopPane上画背景图
class JJPane extends JDesktopPane
{
public void paintBorder(Graphics g)
{
super.paintBorder(g);
ImageIcon ig=new ImageIcon("图片.jpg");
Image im=ig.getImage();
g.drawImage(im,0,0,this.getWidth(),this.getHeight(),this);
}
}
class JOpenFrame extends JInternalFrame
{
JLabel jl;
Icon ic;
Container con;
public JOpenFrame()
{
super("Open",true,true,true,true);
con=this.getContentPane();
setSize(300,300);
setVisible(true);
}
}