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

JDialog trigger action opening JFrame closing problem

K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2418
    
    7

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?


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> 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

Joined: Sep 13, 2007
Posts: 2418
    
    7

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDialog trigger action opening JFrame closing problem