• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I exit?

 
Mike Lipay
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, here's the scenario (coming along pretty well):

I have an application AutoHistory that calls an AddVehicle application as follows:



This works well, and the AddVehicle does it's task of presenting a panel from which vehicle information is collected; then, when a "Save" button is pressed, it adds the information to a file. Now, at the bottom of the AddVehicle panel is a "Return" button; when this button is pressed I would like it to close the AddVehicle application and return to the AutoHistory application.

AddVehicle is defined as:


AutoHistory is defined as:
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
frame.setVisible( false ); ,or
frame.dispose();
 
Mike Lipay
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:frame.setVisible( false ); ,or
frame.dispose();


Thanks! Both seem to work, what is the difference?
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setVisible(false) merely hides the window, whereas dispose() really cleans up the Window. After calling setVisible(false), a call to setVisible(true) will simply show the window again. After dispose() the window has to be completely rebuilt from system resources.
 
Campbell Ritchie
Marshal
Posts: 52587
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the setDefaultCloseOperation method?
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Lipay wrote:
Thanks! Both seem to work, what is the difference?


Did you read the API? Its explained there.

If there is something you don't understand, then quoted the text from the API description.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!