File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Using mouse double-click to close a 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 "Using mouse double-click to close a JDialog" Watch "Using mouse double-click to close a JDialog" New topic
Author

Using mouse double-click to close a JDialog

Randy Johnson
Greenhorn

Joined: Apr 17, 2002
Posts: 22
I am using a JDialog to display a JTable of rows. If a specific row is double-licked, I want to close the JDialog. I have a listener for the MouseEvent, to get the click count. But how do I force a WindowEvent(Window closing action) from the MouseEvent? Is this even the correct approach?
Thanks for the help (past and present)
tormod eriksen
Ranch Hand

Joined: Jan 23, 2002
Posts: 52
I usually call dispose() to close a dialog.
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
I am not sure from a user interface design that clicking on a row in a table is the way to go.
Randy Johnson
Greenhorn

Joined: Apr 17, 2002
Posts: 22
Here's the scenario:
1. User displays a JFrame with JTextFields
2. One of the JTextFields has a button to look
up a list of choices. Each of the choices has
multiple attributes, so:
3. The choice list is actually a JTable/Scroll
Pane, within a JDialog.
3. The user selects a choice and exits the
JDialog. The selected choice is used to pop-
ulate the original JTextField.
I just want the user to be able to double-click the choice, which would make the selection, AND
close the JDialog. Makes sense?
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
I buy that.
Randy Johnson
Greenhorn

Joined: Apr 17, 2002
Posts: 22
So...
Given that scenario, can I somehow force a Window Closing event?
If I use the dispose method, the Dialog is garbage collected (apparently immediately), and I cannot retrieve any of its attributes (I CAN get the attributes after WindowClose is executed).
Any ideas?
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
You could call hide() it or you could set the values within your double click check.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using mouse double-click to close a JDialog
 
Similar Threads
trapping double clicks using getClickCount of MouseEvent
JDialog and JFrame *HELP* !!!
JDialog and JFrame *HELP* !!!
JDialog trigger action opening JFrame closing problem
urgent please help