aspose file tools*
The moose likes Beginning Java and the fly likes First Java Program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "First Java Program" Watch "First Java Program" New topic
Author

First Java Program

Daniel Ashmore
Greenhorn

Joined: Aug 07, 2001
Posts: 2
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

Joined: Sep 29, 2000
Posts: 8521
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).]


"JavaRanch, where the deer and the Certified play" - David O'Meara
Daniel Ashmore
Greenhorn

Joined: Aug 07, 2001
Posts: 2
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: First Java Program