Java Reference
In-Depth Information
4 Creating a Cellular Phone Keypad Applet
The WebPhone company now would like an applet that represents a cellular
phone keypad. As you did in Programming Assignment 2 on page 426, create an
applet that displays a text area across the top of the window, similar to the LCD
panel of most cellular phones. Include buttons for the 10 digits, a star key (*),
and a pound key (#). When clicked, the appropriate digit or symbol should dis-
play in the text area. No additional functionality is required until WebPhone
approves your prototype.
5 Creating a Menu System
Using the menu system displayed in Figure 6-49 on page 423, create a Frame-
based application that has one large TextArea placed in the Center region. Create
the menu system and code the ActionPerformed() event to make at least five of
the menu items work properly.
6 My Classes
Create a Frame-based application that displays an array of nine buttons on a
Panel. Assign the Panel to the Center of your frame. Each button should display
the name of a course in your department. Include a TextField in the South.
When the user clicks a button, the course name should display in the TextField.
7 Adding Extra Buttons to the Calculator
Open the Calculator.java file created for the Calculator application in this
chapter. Modify the application to include buttons for Add to Memory (addM),
Paste from Memory (pasteM), Backspace (Bksp), and Clear (CLR). Create a fifth
row for the new buttons. Increase the length of the keys array. Construct each
button and add the ActionListener to each of the new buttons. Then, in the
actionPerformed() method, write a switch structure to search for each of the
buttons. Write the code for each case. Hint: For the Backspace key, use the
following code:
lcd.setText(lcd.getText().substring(0,lcd.getText().length()-1));
J ava 2
J ava 2
v 5 . 0
8 Researching the setBounds() Method
v 5 . 0
Chapter 6 uses a method called setBounds() to set certain attributes of a Frame;
the setBounds() method is one of the methods inherited from Component class.
Use the online Java documentation for Java 2 ver. 5.0 to look up the setBounds()
method. You will find several setBounds() with different arguments. Write a
paragraph describing each and explain the difference. Draw a picture of the
object hierarchy of the setBounds() method.
J ava 2
J ava 2
v 5 . 0
9 Researching the Frame Class
v 5 . 0
Use the online Java documentation for Java 2 ver. 5.0 to create a tree
or hierarchy chart of the Frame class, similar to the hierarchy chart of AWT
components in Figure 5-17 on page 336. Include both superclasses and
subclasses. Explain how the AWT interacts with the applet class to use Panels
in both applications and applets.
Search WWH ::




Custom Search