Writing a Java applet with a dialog box or separate frame.

This is the second of two assignments doing small applets using the AWT.

For this assignment, you may design your own applet using a separate frame or dialog box. Note that if you put up a frame, you can have a menubar with menus.

Or you can choose to extend the applet that you wrote last time with a dialog box to report some error condition. The dialog box can be defined in a separate class within the same file as the applet. It will be a subclass of Dialog.

  1. Calculator applet.

  2. If you did the calculator applet, you could give an error if the person tries to enter more digits than will fit into the textfield. In the case of this error, you should cause a dialog box to pop up with the error message.

    So in your dialog box class, your box should minimally have a Label with the error message and a button that says something like "ok" that makes the box disappear.

    (You may have noticed in the API under java.lang.Integer that the method parseInt can give the exception NumberFormatException. But you don't need to use a try/catch block to test for it because the calculator applet only allows digits 0-9 to be put into the textfield for parseInt to use. But in a general textfield situation, you may need to test that the input is correctly formatted.)
     

  3. Keyword search applet.

  4. Now this applet does have the case that the user types input into a textfield to be the keyword to search for. Let's suppose that the only input we disallow is the empty string. In this case, you should pop up a dialog box with an error message and an ok button as described above.
You are welcome to make fancier applets and error messages, keeping within the guidelines of showing a separate frame or dialog box.

When you submit your applet, link both the applet (.html file) and the source code (.java file) to your homework page (along with problem and program description as usual). Also please make a note of what browser or appletviewer your applet looks best in.