• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Using mouse double-click to close a JDialog

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I usually call dispose() to close a dialog.
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I buy that.
 
Randy Johnson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could call hide() it or you could set the values within your double click check.
 
I think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic