429
calcFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
calcPane = calcFrame.getContentPane();
calcPane.setLayout(newGridLayout( 4 , 2 ));
calcPane.add(resultLabel);
calcPane.add(register);
calcPane.add(entryLabel);
calcPane.add(inputField);
calcPane.add(add);
calcPane.add(subtract);
calcPane.add(clear);
calcFrame.setVisible(true);
}
}
9.List the statements that relate to the Clear button, describing what each one
does in English.
10.Complete the originalCalculatorproject by adding buttons for multiplication
and division.
11.Write a test plan to test the final project and implement the test plan for
Calculator.
12.Rewrite the Calculatorapplication so that a separate class contains the entire
calculator object. When an object is instantiated, it should create a JPanelcon-
taining the user interface for a calculator. The class should provide a method
that returns the JPanel. The function of the mainmethod can then be simplified
to creating the frame, instantiating a calculator object, getting its panel, and
adding it to the content pane, similar to what we did for the Stationobjects in
the Rainfallprogram.
13.After completing Exercise 12, change mainto instantiate two calculators and
place them into the frame. Be sure to test them thoroughly to ensure that they
operate independently of each other.