forked from mohammedabdulbari/Java-SE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPainting.java
More file actions
41 lines (34 loc) · 758 Bytes
/
Painting.java
File metadata and controls
41 lines (34 loc) · 758 Bytes
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
package painting;
import java.awt.*;
import java.awt.event.*;
class MyFrame extends Frame
{
int x=0,y=0;
MyFrame()
{
super("Painting");
addMouseMotionListener(new MouseAdapter(){
public void mouseMoved(MouseEvent me)
{
x=me.getX();
y=me.getY();
repaint();
}
});
}
public void paint(Graphics g)
{
g.setColor(Color.RED);
g.setFont(new Font("Luminari",Font.BOLD,30));
g.drawString("Hello", x, y);
}
}
public class Painting
{
public static void main(String[] args)
{
MyFrame f=new MyFrame();
f.setSize(500,500);
f.setVisible(true);
}
}