• 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

frame .exit or dispose

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am using netbeans 4.1 guibuilder to build my guis ,,,and i want to add exit menuitem ..but the point is the builder does not name the frame so i cant not use system.exit or dispose ..
anyhelp
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whatever I got from your question you try out the following procedure. Add one menu item as exit. In the actionevent add the code JFrame.setDefaultCloseOperation(1);
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sayan, setDefaultCloseOperation() is not a static method so you can't invoke it on the classname.

Maha, you should have given us a small sample of the code JBuilder generates. Some of us don't use GUI builders (I find they generate confusing and hard-to-maintain code). Without the code we are just guessing as to what the problem is.
You say that the code "does not name the frame". I take it that the code does not create a varaible to store an JFrame instance. There must be a reference SOMEWHERE, otherwise you would not have much of a GUI. I think JBuilder has either: 1) made your class a subclass of JFrame or 2) used a short-lived variable in a constructor or other initalizer. If 1 is the case, all you have to do is invoke the correct methods on "this" (i.e. this.dispose()). If 2 is the case, you need to find where the temporary JFrame instance is declared and move it to a longer-lived declaration:

Then you can invoke methods on the instance variable aFrame.
 
This tiny ad is guaranteed to be gluten free.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic