This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
How do I program a button for closing down the applet? I always thought it was closed manually by the user clicking on the mouse, but I am supposed to write an applet that uses a "close" button to close down.
Well there is more than one way to do this. If you were going to use the X in the corner you would either create a class and extend WindowAdapter, or implement WindowListener. However, since you need a button to do this, you need to create a class to implement something that Button listens to. One of the things that Button listens to is an ActionListener. (You can check this by looking in the API and checking what addXXXListener methods the component has).
Now you have to create a gui and on that qui you need to make a button. When you have your button, you need to create an instance of your listener, and then hook the two together.
Now all you need is to get this in an Applet or a Frame, and all should be good.
"JavaRanch, where the deer and the Certified play" - David O'Meara