aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes modeless 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 "modeless JDialog?" Watch "modeless JDialog?" New topic
Author

modeless JDialog?

Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

What kind of code do I have to update so that the About dialog allows me to select items within the main panel, since the following code seems to enable a modal dialog anyway?






Jon
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

Moved from Beginning Java.


luck, db
There are no new questions, but there may be new answers.
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 563
How does the code snippet you've shown us know that it's creating a JDialog?


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2227
    
    8
since the following code seems to enable a modal dialog anyway?


Post your SSCCE demonstrating the problem.

Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

Rob Camick wrote:
since the following code seems to enable a modal dialog anyway?


Post your SSCCE demonstrating the problem.



I don't know, that's why I asked
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 563
Let's start back at the top:

You could create a method to create and return a modal JDialog with JFrame owner as the owner:



I say, you could. I don't know if that's what you need to do or if it works well in your design. It's one possibility of many.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2227
    
    8
You made the statement:

"since the following code seems to enable a modal dialog anyway?


So prove your statement by posting the code you tested that demonstrated this behaviour.

Then we can look at the code to see what you might be doing wrong.

One line of code doesn't help us.

If you want help then start making an effort by posting a proper SSCCE with your questions showing what you have tried and the results that you get.
Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

Greg Brannon wrote:How does the code snippet you've shown us know that it's creating a JDialog?




The whole code is here...


"Please keep in mind that you get a free default constructor only when your class has no other constructors."
Core Java Vol 1 (8th Ed) P.146.
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 563
Does it work = compile and run then do what you want?

Why are you using Runnable() in your main() method? Would it work without it, just using lines 17 - 19?

I suspect you're having a problem with line 51.
Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

Greg Brannon wrote:Does it work = compile and run then do what you want?

Why are you using Runnable() in your main() method? Would it work without it, just using lines 17 - 19?

I suspect you're having a problem with line 51.


Happy hour?

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19794
    
  20

On line 84 you're passing true to the super constructor, indicating the dialog will be modal. If you turn that into false it will no longer be modal. It will remain in front of your frame but that's how dialogs work.

Greg Brannon wrote:Why are you using Runnable() in your main() method?

Because all GUI related code should run on the EDT, and using a Runnable with EventQueue.invokeLater will cause the code of the Runnable to run on the EDT.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

Rob Spoor wrote:On line 84 you're passing true to the super constructor, indicating the dialog will be modal. If you turn that into false it will no longer be modal. It will remain in front of your frame but that's how dialogs work.

Greg Brannon wrote:Why are you using Runnable() in your main() method?

Because all GUI related code should run on the EDT, and using a Runnable with EventQueue.invokeLater will cause the code of the Runnable to run on the EDT.


What does EDT stand for?

Hence, the dialog will be popped up and not leave the user any other choice than to close the dialog by selecting OK.
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 563
EDT = Event Dispatching Thread.

Rob Spoor wrote:
Because all GUI related code should run on the EDT, and using a Runnable with EventQueue.invokeLater will cause the code of the Runnable to run on the EDT.


Ummmm. I've written a lot of Swing without using Runnable(). I'll have to think on that one.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2227
    
    8
I'll have to think on that one.


There is nothing to think about. That is the way it should be done.

Yes, if all you are dong is creating and showing a simple GUI it will probably work 99% of the time without using the Runnable. However, when problems appear they will be random and those are the hardest problems to solve. So play it safe and don't worry.

Read the section from the Swing tutorial on Concurrency for more information.
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 563
Thinking . . . studying . . . learning, steps leading to understanding. Didn't mean to sound flippant.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: modeless JDialog?