• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

modeless JDialog?

 
Ranch Hand
Posts: 664
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?





 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved from Beginning Java.
 
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How does the code snippet you've shown us know that it's creating a JDialog?
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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



Post your SSCCE demonstrating the problem.

 
Jon Camilleri
Ranch Hand
Posts: 664
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 563
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 664
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 563
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 664
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?

 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jon Camilleri
Ranch Hand
Posts: 664
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 563
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 3324
32
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 563
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thinking . . . studying . . . learning, steps leading to understanding. Didn't mean to sound flippant.
 
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic