Re: Help Menu - opens frame which does not go to front
- From: Babu Kalakrishnan <bkk.ngroup@xxxxxxxxx>
- Date: Thu, 31 Aug 2006 17:11:22 +0530
Ian Wilson wrote:
Andrew Thompson wrote:
The OP might try calling toFront() and requestFocus() *after*
the dialog is visible..
I wonder if SwingUtilities.invokeLater may be of some relevance?
http://forum.java.sun.com/thread.jspa?threadID=666890&messageID=3905383
I use this idiom for a slightly related issue:
SwingUtilities.invokeLater(new Runnable(){
public void run(){
[component].requestFocusInWindow();
}
});
Even though the requestFocusInWindow() method is not really relevant here (it serves the purpose of moving focus to a particular component within the window - not the window itself), this message reminded me of some discussions we had in this newsgroup several years ago - maybe 2000/2001 or so (Don't know if Google still has those archives - and as to how relevant it would still be, because the focus subsystem in swing has undergone drastic changes since then).
Basically the issue used to be that a component would not accept / honour calls to requestFocus() till the Window was realized (or some time that was slightly later than this) - so the workaround was to wrap the requestFocus() call in a SwingUtilities.invokeLater wrapper so that the actual call would take place only during the next cycle of the EDT. And if I remember right, another solution that emerged during those discussions was that one could actually put in the requestFocus() call in a WindowOpened() eent handler of the window, and it would work fine (whereas it used to fail even if the call was immediately after the setVisible(true) call).
So may be the OP could try these workarounds :
1) Register a windowListener on this dialog and call toFront() from the windowOpened() event handler.
2) If that also doesn't work, try to delay the call by one more EDT cycle by wrapping it in an invokeLater wrapper.
BK
.
- References:
- Help Menu - opens frame which does not go to front
- From: johnmmcparland
- Re: Help Menu - opens frame which does not go to front
- From: johnmmcparland
- Re: Help Menu - opens frame which does not go to front
- From: Andrew Thompson
- Re: Help Menu - opens frame which does not go to front
- From: johnmmcparland
- Re: Help Menu - opens frame which does not go to front
- From: Babu Kalakrishnan
- Re: Help Menu - opens frame which does not go to front
- From: Andrew Thompson
- Re: Help Menu - opens frame which does not go to front
- From: Ian Wilson
- Help Menu - opens frame which does not go to front
- Prev by Date: Re: Problem with setUndecorated() method in JFrame
- Previous by thread: Re: Help Menu - opens frame which does not go to front
- Next by thread: how to refresh jComboBox in popupMenuWillBecomeVisible
- Index(es):
Relevant Pages
|