我完成了在我的JFrame
里面添加JInternalFrame
并且添加了方式是点击JMenuItem
图标并且这样做很好,但是当添加了框架时删除了旧组件并出现白色。我所试图做的是设置固定JInternalFrame
位置用出效果的其他成分为什么JInternalFrame删除所有其他组件
对JInternalFrame
package animeaidvlcj;
import javax.swing.JInternalFrame;
/* Used by InternalFrameDemo.java. */
public class MyInternalFrame extends JInternalFrame {
static int openFrameCount = 0;
static final int xOffset = 0, yOffset = 25;
public MyInternalFrame() {
super("Document #" + (++openFrameCount),
true, //resizable
true, //closable
true, //maximizable
true);//iconifiable
//...Create the GUI and put it in the window...
//...Then set the window size or call pack...
setSize(300,300);
//Set the window's location.
setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
}
}
动作代码的代码的其他组件
Action newAction = new AbstractAction("New", newIcon) {
@Override
public void actionPerformed(ActionEvent e) {
desktop = new JDesktopPane();
createFrame();
setContentPane(desktop);
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
}
};
创建方法
protected void createFrame() {
MyInternalFrame frame = new MyInternalFrame();
frame.setVisible(true); //necessary as of 1.3
desktop.add(frame);
try {
frame.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
}
为了尽快提供更好的帮助,请发布[MCVE](http://stackoverflow.com/help/mcve)(最小完整和可验证示例)。 –