OK, now you've got an application with a frame that cannot close itself and doesnt do anything EVEN THOUGH it has an "actionPerformed" statement. Let's fix that, and give it a button that can shut down the program in a simple way. Here's what you need to do:
A) just below the line where you declared a Frame:
Frame one;
add this line to declare a button
Button exit;
B) add the button to the frame. You should know the three important lines of code used to add a button to a frame by now; just make you type them in directly below this line:
one.setLayout(new FlowLayout());
C) Tell this button how to close the whole program by adding this code block to the actionPerformed method:
if (e.getSource() == exit)
{//add
System.exit(0); //thats a zero in there, not an O
}// All over, let's quit
Re-compile your program then run it to see if the button shuts it all down!
Cheers,
Uncle Paulie
Tuesday, February 10, 2009
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment