Java 如何从所有打开的jinternalframe将jinternalframe带到前面?
这是我的源代码。 我无法将我的Java 如何从所有打开的jinternalframe将jinternalframe带到前面?,java,swing,netbeans,jinternalframe,Java,Swing,Netbeans,Jinternalframe,这是我的源代码。 我无法将我的JInternalframe放在前面。 我已经尝试了很多代码,但都不起作用 private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) { boolean b = true; JInternalFrame[] j = jDesktopPane1.getAllFrames();
JInternalframe
放在前面。
我已经尝试了很多代码,但都不起作用
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
boolean b = true;
JInternalFrame[] j = jDesktopPane1.getAllFrames();
no = new NewOrder();
for (JInternalFrame Ji : j) {
if (Ji.isShowing()) {
b = false;
break;
}
}
if (!b) {
no.requestFocus(true);
} else {
dm = jDesktopPane1.getDesktopManager();
jDesktopPane1.add(no);
dm.setBoundsForFrame(no, (jDesktopPane1.getWidth() - no.getWidth()) / 2, (jDesktopPane1.getHeight() - no.getHeight()) / 2, no.getWidth(), no.getHeight());
dm.openFrame(no);
no.setVisible(true);
}
}
及
谁能解释一下为什么会这样?
谢谢大家! 使用方法;举出了一个完整的例子。为方便起见,请从调用方法,如图所示
附录:典型的实现可能如下所示
class MyFrame extends JInternalFrame {
private Action action;
MyFrame(…) {
…
action = new AbstractAction(name) {
@Override
public void actionPerformed(ActionEvent ae) {
try {
MyFrame.this.setSelected(true);
} catch (PropertyVetoException e) {
e.printStackTrace();
}
}
};
}
public Action getAction() {
return action;
}
}
我找到了
NewOrder no = new NewOrder();
if (no.isShowing()) {
no.toFront();
} else {
lo.LoadInterfaces(no, jDesktopPane1);
}
只是删除了初始化。。并立即进行初始化和声明。谁能解释一下为什么会发生这种事。求你了。我感觉你让它工作了;如果你仍然有问题,请编辑你的问题,包括一个显示你的方法;我已经抽象了上面的基本用法。你用什么来表示名称值?只是一个
字符串
;与所引用的示例相同。toFront()
有条件地调用setSelected()
@Catalina Island是否影响不同的工作计划?必须显示内部框架或相应的图标以允许选择。
NewOrder no = new NewOrder();
if (no.isShowing()) {
no.toFront();
} else {
lo.LoadInterfaces(no, jDesktopPane1);
}