• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

windowClosing(WindowEvent e) execution delayed

 
Ranch Hand
Posts: 191
Netbeans IDE
  • 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 in which I have various JComponents such as JRadioButton, JCheckBox, and JTextField classes. When a user closes the Dialog using the x button of the Dialog itself, the Components are programmed be left in their original state, which in this case is unselected or JTextField empty. I have created a method called restoreControls() to restore the Components this way. I have placed this method in the windowClosing(WindowEvent e) method as seen below. The content of the method is executed AFTER a time delay of a mere fraction of a second because when the Dialog is requested to become visible (it is set to be hidden instead of destroyed), the text in the JTextField is seen during this very brief delay, but it does disappear as programmed to do so. I cannot understand why the method is not executed right after the Window is closed. I have tried windowClosed(WindowEvent e), and it is the same effect. I have tried wrapping the Component methods such as setSelected(false) or setText("") in an evokeLater() method and it makes no difference.

 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try pack()ing the dialog before you redisplay it using setVisible(true)
 
Isaac Hewitt
Ranch Hand
Posts: 191
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow! using pack() was indeed all it took placed before the restoreControls() method. Thank you Darryl.
 
No thanks. We have all the government we need. This tiny ad would like you to leave now:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic