Find the error(s) in the following code. This is the definition for an actionPerformed event handler for a JButton. This event handler should draw a rectangle on a JPanel. Assume that the classes used are those from the Drawing Shapes application.
```
1 private void drawImageJButtonActionPerformed( ActionEvent event )
2 {
3 // set shape
4 MyShape rectangle = new MyRectangle( 2, 3, 40, 30 );
5
6 // set color
7 rectangle.setColor( Color.ORANGE );
8
9 // add rectangle to shapesArrayList
10 shapesArrayList.add( rectangle );
11
12 } // end method drawImageJButtonActionPerformed
```
The MyRectangle class does not contain a setColor method; however, the con- structor does take a fifth argument to specify the color of the rectangle.
```
1 private void drawImageJButtonActionPerformed( ActionEvent event )
2 {
3 // set shape
4 MyShape rectangle = new MyRectangle( 2, 3, 40, 30, Color.ORANGE );
5
6 // add rectangle to shapesArrayList
7 shapesArrayList.add( rectangle );
8
9 } // end method drawImageJButtonActionPerformed
```
You might also like to view...
The text “Hello there, my friend.” is an example of what type of capitalization?
a. sentence-style capitalization. b. book-title capitalization. c. Neither of the above. d. Both of the above.
_____ refers to the act of breaking into a computer or network.
A. ?Authentication B. ?Encrypting C. ?Authorization D. ?Hacking
A Quick Style is a combination of different formats that you can apply to shapes or other objects
Indicate whether the statement is true or false
Critical Thinking Questions Case 9-1 ?? Eamon is planning to start an online store that specializes in books and electronics. Since it's his first business, he has a lot of doubts. Help Eamon set up his business by answering the following questions. ? ? Eamon wants to provide a discount to premium buyers who order in large quantities. He wants to create a code for each price and share it with them. Also, he wants to ensure that only the premium buyers can decipher the code shared. In this scenario, which of the following codes would you suggest that Eamon use?
A. Cipher code B. Mnemonic code C. Action code D. Derivation code