Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #2627 > unrolled thread
| Started by | "Jason Cavett" <jason.cavett@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:40 +0000 |
| Last post | 2011-04-27 15:40 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.java.gui
Menu Removes Focus "Jason Cavett" <jason.cavett@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Menu Removes Focus "Steve W. Jackson" <steve.w..jackson@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
| From | "Jason Cavett" <jason.cavett@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:40 +0000 |
| Subject | Menu Removes Focus |
| Message-ID | <1192199555.846573.118100@v29g2000prd.googlegroups.com> |
To: comp.lang.java.gui,comp.l I'm curious - how do I know what component has focus when I need to pop up a menu to complete a task. For example, in my JTree, I have a popup menu that comes up when I right click on the tree. Well, the JTree is the "real" object that has focus (for a paste/cut/copy/whatever), but now that the menu is shown, Java thinks it is the thing to have the real focus. Hopefully that makes sense. Thanks --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Steve W. Jackson" <steve.w..jackson@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:40 +0000 |
| Message-ID | <stevewjackson-FCB388.14163415102007@individual.net> |
| In reply to | #2627 |
To: comp.lang.java.gui,comp.l In article <1192199555.846573.118100@v29g2000prd.googlegroups.com>, Jason Cavett <jason.cavett@gmail.com> wrote: > I'm curious - how do I know what component has focus when I need to > pop up a menu to complete a task. > > For example, in my JTree, I have a popup menu that comes up when I > right click on the tree. Well, the JTree is the "real" object that > has focus (for a paste/cut/copy/whatever), but now that the menu is > shown, Java thinks it is the thing to have the real focus. > > Hopefully that makes sense. > > > Thanks The popup really is the item with "real" focus in this case. Only one component at any time can have "the focus" in your application. When a popup is displayed, it's a window of a sort and deactivates the one containing your tree. But you'll find in the API for Window (one of the superclasses to JDialog and JFrame) that there's a method named getMostRecentFocusOwner which will identify the Component owning the focus when the window regains focus. HTH, = Steve = -- Steve W. Jackson Montgomery, Alabama --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web