• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Using mouse double-click to close a JDialog

 
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)
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I usually call dispose() to close a dialog.
 
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.
 
Men call me Jim. Women look past me to this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!