-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyFrame.java
More file actions
43 lines (39 loc) · 1021 Bytes
/
Copy pathMyFrame.java
File metadata and controls
43 lines (39 loc) · 1021 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
42
43
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
//------------------------------------------------class=MyFrame----------------------------------------------------//
public class MyFrame extends Frame{
String km="---TEST---", mm="";
int x=30,y=30;
public MyFrame(){
addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);}});
addMouseListener(
new MouseAdapter(){
public void mousePressed(MouseEvent me){
x=me.getX();
y=me.getY();
mm=x+","+y;
repaint();
}});
addKeyListener(
new KeyAdapter(){
public void keyTyped(KeyEvent ke){
km+="\n"+ke.getKeyChar();
repaint();
}});
}
public void paint(Graphics g){
g.drawString(km,10,40);
g.drawString(mm,x,y);
}
//-------------------------------------------class=main inside MyFrame----------------------------------------------//
public static void main(String args[]){
MyFrame MF=new MyFrame();
MF.setSize(300,200);
MF.setTitle("AWT based window");
MF.setVisible(true);
}
}