Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using mouse double-click to close a JDialog

 
Randy Johnson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I usually call dispose() to close a dialog.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I buy that.
 
Randy Johnson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could call hide() it or you could set the values within your double click check.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic