• 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

JDialog trigger action opening JFrame closing problem

 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, I have a weird situation. I have a modal JDialog window with buttons. I click a button open a JFrame which has a close button at the bottom. Now in the JFrame, if I "click" the close button - nothing. If I use keyboard shortcut it closes.

In JFrame, the close button is an action with tool tip set. When I mouse over the button, 1) the tool tip doesn't show, 2) won't click. If I change all that to anonymous inner class using action listener - same result.

Is there something about JDialog and JFrame interaction I need to know??

Oh in this class there is a constructor that takes an int and JDialog. Could this JDialog affect my JFrame closing operation?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> Is there something about JDialog and JFrame interaction I need to know??

if the dialog is modal ("I have a modal JDialog window with buttons"), there is no interaction.

change the dialog's modality to false, then try clicking your button
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Michael, I did set the JDialog's modal to false before I show the JFrame. If I didn't the JDialog window will be in front of the JFrame blocking its view.

If I don't use a JDialog at all, then my code just run through because the JDialog loads inside a switch statement. If not modal, my switch statement seems pointless.



So without modal, it just go to loadConfig() method which has no keys in the properties.

The action code also uses a switch


I mentioned the action's constructor parms int and JDialog. If I dialog.setModal(false) inside the action's constructor, then it will go to loadConfig() as if the action makes it invisible.


The more I think about it, its more of my switch statement flow problem more than getting the JDialog to work properly. Cos if eventually I want to make it mode-less, I better use a JFrame.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic