Java 如何防止激活JInternalFrame
我尝试创建多文档界面。我使用JDesktopPane并在其上添加了三个JInternalFrame。 它工作得很好,但如果我激活第一个窗口,它会关闭第二个和第三个窗口,我无法再打开它们。 如何防止激活JInternalFrame 这就是我创建JInternalFrame的方式:Java 如何防止激活JInternalFrame,java,swing,jinternalframe,jdesktoppane,Java,Swing,Jinternalframe,Jdesktoppane,我尝试创建多文档界面。我使用JDesktopPane并在其上添加了三个JInternalFrame。 它工作得很好,但如果我激活第一个窗口,它会关闭第二个和第三个窗口,我无法再打开它们。 如何防止激活JInternalFrame 这就是我创建JInternalFrame的方式: protected void createFrame() { MyInternalFrame frame = new MyInternalFrame(); frame.setVisible(true);
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) {}
}
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);
}
}
还有一个类MyInternalFrame:
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) {}
}
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);
}
}
为了更快地获得更好的帮助,请发布一个or。没有理由发生这种情况,您的代码中一定有一些内容没有显示出来us@MadProgrammer,也许我对这个问题描述得不好。我为我的英语感到抱歉。我的代码中没有问题。我的问题是我不知道如何更改代码。我想阻止激活我的一个JintenalFrame,但我不知道怎么做。为了尽快获得更好的帮助,请发布一个or。没有理由发生这种情况,您的代码中一定有某些内容没有显示us@MadProgrammer,也许我对这个问题描述得不好。我为我的英语感到抱歉。我的代码中没有问题。我的问题是我不知道如何更改代码。我想阻止激活我的一个JintenalFrame,我不知道怎么做。