• 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

Enable button when jframe window is closed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have smalll application, containing 2 jFrame forms.

When clicking on a menu item in form 1, on the current form a button is disabled, and a second form is displayed.
When the second form is closed, the button on the first form has to be re-enabled.

Does anyone know how to do this? How to get the button object on the first form and change it's propeties?

Thanks
 
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
WindowListener
 
John Devlon
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Darryl,

Thanks for your feedback.

I've tried on Form 1 to...

if (wdForm2 == null){
wdForm2 = new Form2();

wdForm2.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent ev) {
btnStart.setEnabled(true); // Located on form 1
}
});

}
wdForm2.setVisible(true);



.. but it doesn't seem to work...

Has anyone any suggestion?

Thanks
 
Bartender
Posts: 825
5
Python Ruby Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ItDoesntWorkIsUseless (<- click), please be more specific. The general principle proposed above should do the trick. Though, I would suggest you never have more than one JFrame per application; use JDialog instead.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Devlon wrote:
I have smalll application, containing 2 jFrame forms.


Bad usability. I would recommend using something like a CardLayout or explicitly replacing visual component containers
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have smalll application, containing 2 jFrame forms.



Also, agree this is a bad design. An application should only contain a single JFrame.

If you need child windows, then you should create a modal JDialog. There is no need to disable the original button because you won't be able to access the the frame again until you close the dialog.

Or, has already been mentioned you can use a CardLayout.
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic