Writing a Java applet with basic components and layouts

In the last assignment, I forgot that you may need reminders about how to run applets. Apparently everyone figured it out o.k. I should have linked these applet instructions.

Now for this assignment, there is also a choice between two simple examples using basic components and layouts.

  1. Simple calculator applet.

  2. Look at the example problem 10.10 on page 577 of the Deitel textbook, which shows a GUI for a calculator. For your applet create a similar GUI with the textfield at the top for the calculator display and with buttons for numbers and operators. You should have at least one arithmetic operator, such as "+", "clear", and "=".

    You may use a combination of border layout and grid layout, such as shown in the class examples BorderLayout1.java.

    To implement the buttons:

  3. Keyword search applet.

  4. For this applet, you will need to make up some data to be searched. I suggest having an array of song titles (each song title is represented as a String in one element of the array) and an accompanying array of artists. Then the GUI will represent finding song titles by keyword search. There will be a textfield for the user to type in a keyword. Then you should also have a choice of case sensitive or case insensitive search. This can be represented by two radio buttons, a drop-down menu or list.

    You might introduce a boolean variable to keep track of whether the search is to be case sensitive or not. When the user selects the case sensitive checkboxes, choice or list, you can just change the value of this variable. Then when the user hits enter on the keyword, design a search function to search the strings in the song title array. You can use the String method indexOf to find occurences of the keyword in each string in the array. Design a way to make the search case insensitive (probably using string method toLowerCase), depending on whether the search is supposed to be case sensitive or not.

    Use a layout of some form; I leave the design up to you.

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.