ButtonListener class The ButtonListener class implements ActionListener interfac
ID: 3553558 • Letter: B
Question
ButtonListener class
The ButtonListener class implements ActionListener interface defined in java.awt.event package. It must implement the following method:
public void actionPerformed(ActionEvent event)
In this method, based on the "Undo" button or ?Erase? the last drawn rectangle or all the rectangles should be erased. Note in case there is no rectangle drawn in the drawing panel, nothing will happen even when the "Undo" button is pushed. You should make sure that your program does not crash in this case. The ?Erase? button clears the list and repaint the canvas.
ColorListener class
The ColorListener class implements ActionListener interface defined in java.awt.event package. It must implement the following method:
public void actionPerformed(ActionEvent event)
In this method, the color chosen by a user using JRadioButton is assigned as a color to be used to draw the rectangle.
PointListner class
The PointListener class implements MouseListener and MouseMotionListener interface. It must implement the following method:
public void mousePressed (MouseEvent event)
public void mouseReleased (MouseEvent event)???? ???
//? mouseReleased method takes the point where a mouse is released
//using the point and the pressed point to create a rectangle, add it to the ArrayList, and call paintComponent method.
public void mouseDragged(MouseEvent event) //mouseDragged method takes the point where a mouse is dragged,
//and call paintComponent nethod
Other methods from MouseListener can be left as blank.
Note that these listener classes and CanvasPanel class are defined as nested classes inside of the WholePanel class
Explanation / Answer
Find the code here : http://ideone.com/a8NdKK
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.