如何将jinternalframe从所有打开的jinternalframes移到最前面? [英] How to bring jinternalframe to front from all opened jinternalframes?
本文介绍了如何将jinternalframe从所有打开的jinternalframes移到最前面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的源代码.
我无法将JInternalframe
放在最前面.
我已经尝试了很多代码,但是没有用.
This is my source code.
I can't get my JInternalframe
to the front.
I have tried many codes out there, but nothing worked.
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);
}
}
和
NewOrder no = new NewOrder();
if (no.isShowing()) {
no.toFront();
} else {
lo.LoadInterfaces(no, jDesktopPane1);
}
任何人都可以向我解释为什么会这样吗? 谢谢!
Can any body please explain me why this was happened? Thank you!
推荐答案
使用 setSelected()
方法. html"rel =" nofollow noreferrer> JInternalFrame
; 此处引用了完整的示例.为方便起见,请从 Action
调用该方法,如此处所示.
Use the setSelected()
method of JInternalFrame
; a complete example is cited here. For convenience, invoke the method from an Action
, as shown here.
附录:典型的实现可能看起来像这样.
Addendum: A typical implementation might look like this.
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;
}
}
这篇关于如何将jinternalframe从所有打开的jinternalframes移到最前面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文