
Java Programming
Exercise-02
Day-04
Add following code in your action method to avoid exceptions
if(event.target instanceof Button){
s=(String)action;
label1.setText(s);
}
1. Activity-6
a. Write an applet for a super store and do the following
i. Create a String array “Items” for 10 strings
ii. Create a String variable “customerName”
iii. Set the layout to FlowLayout aligned to left
iv. Add a text filed with label “Customer Name”
v. Add 10 Check boxes with labels, each label is the name of an item in the superstore
vi. Add a text area with the label “Your Item List”
vii. Add a button with label “Show List”
b. Write code in the action method for the “Show List” button for the following action when this
button is pressed
i. Check the state of each checkbox
ii. If a checkbox is checked get the label associated with the checkbox and save it to the
“Item” array
iii. Get the text from the text field (the customer name) and save to the variable
“customerName” (if text field is empty save “Anonymous” in the variable)
iv. Display customer name in the text area
v. Display the contents of the array in the Text area
2. Activity-7
a. Add a button “Clear” to your super store applet, the button when pressed should uncheck all the
checkboxes
b. Add a button “Check All” to your super store applet, the button when pressed should check all
the checkboxes
c. Add a button “New Customer” to your super store applet, the button when pressed should
i. Uncheck all the checkboxes
ii. Clear the text field
iii. Clear the text area
3. Activity- 8
a. Try super store applet using some different layout