我尝试创建多文档界面。我使用JDesktopPane并在其上添加了三个JInternalFrame。 It looks like that: 它工作得很好,但如果我激活第一个窗口,它会关闭第二个和第三个窗口,我不再能够打开它们。 如何防止激活JInternalFrame?
这就是我创建JInternalFrame的方法:
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) {}
}
并且有MyInternalFrame类:
public class MyInternalFrame extends JInternalFrame{
static int openFrameCount = 0;
static final int xOffset = 30, yOffset = 30;
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);
}
}