File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

First Java Program

 
Daniel Ashmore
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a very simple Class (class MyAccounts extends Frame implements ActionListener) that shows a frame with a menubar and a menu containing menu item 'exit', I handle the selection of this menu item as follows;
public void actionPerformed(ActionEvent evt)
{
if ("exit".equals(what))
{
dispose();
System.out.println("doing exit");
}
.
.
.
This works as far as it goes (i.e. it removes the frame from the screen.) However, for the life of me I cannot figure out how to regain control of the program. As it is now, The program simply hangs in limbo, I assume waiting for more input from the user. I guess my basic question is, how do I regain control when an object has finished its useful life?

 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't happen to be a procedural programmer would you?
Since the myAccounts class IS the application (at least the way you describe it) and it IS the Frame also, when you dispose of the frame what is left? When you dispose of a Frame you are releasing the operating system resources that do the work for the frame, but you are not killing the thread that you are running in.
If you truely want to exit you should use
System.exit(0);
If you really have other stuff that you want to do, you should be doing it within an object so, you will need to show us the code and explain more.

[This message has been edited by Cindy Glass (edited August 07, 2001).]
 
Daniel Ashmore
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou Cindy.
As a matter of fact, what little programming experience I do have comes from a procedural backround. The system.exit(0); call worked; I guess I need to take a closer look at what is happening as far as threads implemented by the virtual machine ect..
Thanks again.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic