Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1356 > unrolled thread
| Started by | "Lionel van den Berg" <lionel.van.den.berg@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:32 +0000 |
| Last post | 2011-04-27 15:32 +0000 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.java.gui
Giving JDialog the correc "Lionel van den Berg" <lionel.van.den.berg@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
Re: Giving JDialog the co "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
Re: Giving JDialog the co "Dan Andrews" <dan.andrews@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
Re: Giving JDialog the co "Lionel van den Berg" <lionel.van.den.berg@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
| From | "Lionel van den Berg" <lionel.van.den.berg@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:32 +0000 |
| Subject | Giving JDialog the correc |
| Message-ID | <460f7681$1@dnews.tpgi.com.au> |
To: comp.lang.java.gui Often I find an error or want to give the user some information I am doing so in a class that is an extension of JPanel. However, this JPanel may have another JPanel as it's parent, or some other Container class. So if I have to show a modal JDialog or JOptionPane I don't know what to provide as the parent. Providing null to a JDialog means that if I click on another window and then back onto the original, the dialog dis-appears behind the main window. Does anyone have a design solution to this? I sort of thought that I might have a class that tracks the active window, but then all windows would have to register and de-register with this class . . . doesn't seem very convenient. Any help appreciated. Lionel. --- * 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 | "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:32 +0000 |
| Subject | Re: Giving JDialog the co |
| Message-ID | <700ce1ff1293b@uwe> |
| In reply to | #1356 |
To: comp.lang.java.gui Lionel van den Berg wrote: >Often I find an error or want to give the user some information I am >doing so in a class that is an extension of JPanel. However, this JPanel >may have another JPanel as it's parent, or some other Container class. . >Providing null to a JDialog means that if I click on another window and >then back onto the original, the dialog dis-appears behind the main window. > >Does anyone have a design solution to this? I am still not sure what the question is, but note that if you can find your way back to the 'root' JFrame/JWindow etc., you can use that as the owner of the JDialog. Methods that might help with this are possibly..* JComponent.getRootPane(), or a loop that asks for the Component.getParent() until getParent() returns 'null' (that Component will be the JFrame or JWindow). * ..and I am sure there is a method that actually returns the JFrame/JWindow directly, but I cannot recall what it is, at this moment. -- Andrew Thompson http://www.athompson.info/andrew/ --- * 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] | [next] | [standalone]
| From | "Dan Andrews" <dan.andrews@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:32 +0000 |
| Subject | Re: Giving JDialog the co |
| Message-ID | <1175444052.070924.271230@q75g2000hsh.googlegroups.com> |
| In reply to | #1356 |
To: comp.lang.java.gui On Apr 1, 3:09 am, Lionel van den Berg <lione...@gmail.com> wrote: [snip] > Does anyone have a design solution to this? I sort of thought that I > might have a class that tracks the active window, but then all windows > would have to register and de-register with this class . . . doesn't > seem very convenient. > > Any help appreciated. > > Lionel. Hi Lionel, In addition to Andrew's solution, Frame has a method named getFrames which will return a list of all Frames and if you only have one JFrame you could use: JFrame myFrame = (JFrame)Frame.getFrames()[0]; In JDK 1.6 you can use Window.getWindows() too. Otherwise, you will need to determine which of the Frames isActive() or use some other method to determine if the frame is the frame you want. Cheers, Dan Andrews ------------------- http://www.ansir.ca --- * 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] | [next] | [standalone]
| From | "Lionel van den Berg" <lionel.van.den.berg@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:32 +0000 |
| Subject | Re: Giving JDialog the co |
| Message-ID | <4610244e$1@dnews.tpgi.com.au> |
| In reply to | #1361 |
To: comp.lang.java.gui Dan Andrews wrote: > On Apr 1, 3:09 am, Lionel van den Berg <lione...@gmail.com> wrote: > [snip] >> Does anyone have a design solution to this? I sort of thought that I >> might have a class that tracks the active window, but then all windows >> would have to register and de-register with this class . . . doesn't >> seem very convenient. >> >> Any help appreciated. >> >> Lionel. > > Hi Lionel, > > In addition to Andrew's solution, Frame has a method named getFrames > which will return a list of all Frames and if you only have one JFrame > you could use: > > JFrame myFrame = (JFrame)Frame.getFrames()[0]; > > In JDK 1.6 you can use Window.getWindows() too. Not using 1.6 yet :(. Decided to support 1.5 as it's still not too old. > Otherwise, you will need to determine which of the Frames isActive() > or use some other method to determine if the frame is the frame you > want. Excellent. I do Frame.getFrames(); and then iterate through them calling isActive() to get the active frame. It now works perfectly. Thanks to both responses. :). Lionel. --- * 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