33import java .awt .event .ActionEvent ;
44import java .awt .event .MouseEvent ;
55
6- import javax .swing .ImageIcon ;
7-
86import actions .AddLazyJavaClassAction ;
97import buttons .ToolButton ;
108import ui .PaintPanel ;
@@ -27,6 +25,9 @@ public AddClassTool(PaintPanel panel) {
2725 public void start (PaintPanel panel ) {
2826 }
2927
28+ /**
29+ * create a toolButton for this tool, and set icons
30+ */
3031 @ Override
3132 public void createButton () {
3233 // TODO Auto-generated method stub
@@ -48,11 +49,15 @@ public void reset() {
4849
4950 }
5051
52+ /**
53+ * when mouse click paintPanel, add class dialog will pop up, and a class
54+ * component will be added to where mouse was clicked
55+ */
5156 @ Override
5257 public void mouseClicked (MouseEvent e ) {
53- // TODO Auto-generated method stub
5458 AddLazyJavaClassAction action = new AddLazyJavaClassAction (panel );
5559 if (action .canPerformAction ()) {
60+ // set the starting point for class component
5661 action .setXY (e .getX (), e .getY ());
5762 action .performAction ();
5863 }
@@ -96,6 +101,9 @@ public void mouseMoved(MouseEvent e) {
96101
97102 }
98103
104+ /**
105+ * change the cursor when add button is clicked
106+ */
99107 @ Override
100108 public void actionPerformed (ActionEvent e ) {
101109 panel .setNewCursor (CustomCursors .addComponentcursor ());
0 commit comments