-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAppWindow.java
66 lines (56 loc) · 1.34 KB
/
AppWindow.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
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.awt.*;
import java.awt.event.*;
import java.applet;
/* <applet code = "AppWindow" height = 300 width = 300> </applet> */
public class AppWindow extends Frame implements MouseListener
{
String msg = " ";
public AppWindow()
{
addMouseListener(this);
addWindowListener(new MyWindowAdapter());
}
public void paint(Graphics g)
{
g.drawString(msg,40,40);
}
public void mousePressed(MouseEvent me)
{
msg = "Mouse is pressed";
repaint();
}
public void mouseReleased(MouseEvent me)
{
msg = "Mouse is released";
repaint();
}
public void mouseEntered(MouseEvent me)
{
msg = "Mouse entered the screen";
repaint();
}
public void mouseExited(MouseEvent me)
{
msg = "Mouse exited the screen";
repaint();
}
public void mouseClicked(MouseEvent me)
{
msg = "Mouse is clicked";
repaint();
}
class MyWinAdapter extends WindowAdapter
{
public void Window(toString(WindowEvent we))
{
System.exit(0);
}
}
public static void main(String args[])
{
AppWindow aw = new AppWindow();
aw.getSize(100,100);
aw.setTitle("AWT based Application");
aw.setVisible(true);
}
}