aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JInternalFrame vs JDialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JInternalFrame vs JDialog" Watch "JInternalFrame vs JDialog" New topic
Author

JInternalFrame vs JDialog

Michael Labuschagne
Ranch Hand

Joined: May 08, 2007
Posts: 56

I need to change my code from using a JDialog to using a JInternalFrame...

My problem is that when I do this, in code it will continue executing subsequent code if I use a JInternalFrame, but whilst I use the JDialog it waits for user response before continuing.

How would I use a JInternalFrame (without any buttons as you would have on a JDialog) and only continue execution of the code after it has been closed?

My current code:

Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Originally posted by Michael Labuschagne:
I need to change my code from using a JDialog to using a JInternalFrame...

My problem is that when I do this, in code it will continue executing subsequent code if I use a JInternalFrame, but whilst I use the JDialog it waits for user response before continuing.


You can try something like:

JOptionPane.showInternalOptionDialog(this, djt.djPanel(), taskModel.getTaskName(), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);

If that doesn't suit your needs you can find various ways
of rolling your own if you look around on the net.


bitguru blog
Michael Labuschagne
Ranch Hand

Joined: May 08, 2007
Posts: 56

OK, tried that it works as an InternalFrame but I need it to be non-modal, is that possible, in a JOptionPane???
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Originally posted by Michael Labuschagne:
OK, tried that it works as an InternalFrame but I need it to be non-modal, is that possible, in a JOptionPane???


My mistake. But making it modal is the hard part. If you want non-modal then there are many ways you can do it. In your case, it might be easiest to replace your call to pane.createDialog() to pane.createInternalFrame(). (Don't forget to add() the internal frame to your JDesktopPane.)
Michael Labuschagne
Ranch Hand

Joined: May 08, 2007
Posts: 56

Tried your suggestion but keep getting the following error:

java.lang.IllegalArgumentException: illegal component position

I've modified the code and played around with it but still the same error.



Other internal frames are working correctly on this JDesktopPane not sure what the problem is.

How can I get it stop executing the rest of the code in the method untill the window is closed, or will it do that now anyway?

Thanks a lot, your help is appreciated!
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Originally posted by Michael Labuschagne:
Tried your suggestion but keep getting the following error:

java.lang.IllegalArgumentException: illegal component position




By illegal component position it doesn't mean the x-y position, but the index within the container. What container are you adding the JInternalFrame to? (It's not clear from your code what the type of this is, but I'm guessing it's not a JDesktopPane.)

btw, what's the motivation for using a JOptionPane instead of creating a JInternalFrame directly?

[edit: typo]
[ July 13, 2007: Message edited by: Brian Cole ]
Michael Labuschagne
Ranch Hand

Joined: May 08, 2007
Posts: 56

I'm adding the JInternalFrame to a JDesktopPane (the class this code is in, extends JDektopPane)...

All I need is an InternalFrame that creates my Dialog which is non-Modal and stops executing successive code, after the InternalFrame deceleration until the frame is closed. JOptionPane waits for you to either close the frame or click OK, cancel and then continues executing code in the program how can I achieve this with JInternalFrame???

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JInternalFrame vs JDialog