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);
}
}
and
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!
Use the
setSelected()
method ofJInternalFrame
; a complete example is cited here. For convenience, invoke the method from anAction
, as shown here.Addendum: A typical implementation might look like this.
I found it..
It was just remove the initialization.. And do initialization and declaration at once. Can any body please explain me why this was happened. Please.