My code:
1 // ubuntu windows endl
2
3 import java. awt .*;
4 import java. awt. event .*;
5 import java. awt. image .*;
6 import java. io .*;
7 import javax. swing .*;
8 import javax. imageio .*;
9
10 class PainterCanvas extends Canvas {
11
12 public PainterCanvas (Color foregroundColor, int initPaintType, float lineWidth, float [] dashArray, float dashPhase, Dimension size ){
13 setColor (foregroundColor );
14 setBackground (COLOR_BACK );
15 paintType = LINE;
16 setPaintType (initPaintType );
17 paintStroke = new BasicStroke ();
18 setLineWidth (lineWidth );
19 setLineDash (dashArray, dashPhase );
20 setBufferedDimension (size );
21 startX = startY = endX = endY = 0;
22 drawBuffer = false;
23 pressed = false;
24 setCursor (Cursor. getPredefinedCursor (Cursor. CROSSHAIR_CURSOR ));
25 addMouseListener (new
26 MouseAdapter (){
27 public void mousePressed (MouseEvent me ){
28 if (! Pressed ){
29 startX = me. getX ();
30 startY = me. getY ();
31 pressed = true;
32}
33}
34 public void mouseReleased (MouseEvent me ){
35 if (pressed ){
36 endX = me. getX ();
37 endY = me. getY ();
38 pressed = false;
39 drawBuffer = true;
40 repaint ();
41}
42}
43}
44 );
45 addMouseMotionListener (new MouseMotionAdapter (){
46 public void mouseDragged (MouseEvent me ){
47 &