-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScribble.java
53 lines (47 loc) · 1.34 KB
/
Scribble.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.awt.*;
import java.awt.event.*;
public class Scribble extends Frame implements MouseListener,MouseMotionListener
{
public int last_x,last_y;
Scribble()
{
this.addMouseListener(this);
this.addMouseMotionListener(this);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
public void mousePressed(MouseEvent e)
{
last_x=e.getX();
last_y=e.getY();
}
public void mouseDragged(MouseEvent e)
{
Graphics g=this.getGraphics();
int x=e.getX(),y=e.getY();
g.drawLine(last_x,last_y,x,y);
last_x=x;
last_y=y;
}
public void mouseClicked(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseMoved(MouseEvent e){}
public void mouseRelease(MouseEvent e){}
public static void main(String args[])
{
Scribble k=new Scribble();
k.setTitle("scribble");
k.setSize(450,400);
k.setVisible(true);
}
@Override
public void mouseReleased(MouseEvent me) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}