-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcomponents_position.java
executable file
·128 lines (103 loc) · 2.96 KB
/
components_position.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.awt.image.*;
class mouse_event implements java.awt.event.MouseListener,java.awt.event.WindowListener{
private Frame frame;
mouse_event(Frame frame){
this.frame=frame;
}
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
System.out.println("Key:"+arg0.getButton()+" Clickcount:"+arg0.getClickCount());
}
public void mouseEntered(MouseEvent arg0) {
}
public void mouseExited(MouseEvent arg0) {
}
public void mousePressed(MouseEvent arg0) {
}
public void mouseReleased(MouseEvent arg0) {
}
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub
System.out.println("window.close");
}
public void windowClosing(WindowEvent arg0) {
// TODO Auto-generated method stub
System.out.println("window.closing");
this.frame.dispose();
}
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
}
public class main_class extends Applet{
Button my_button;
Button my_button2;
Button my_button3;
Frame f;
Panel p1;
Panel p2;
Panel p3;
mouse_event mouseevent;
public void init(){
f=new Frame();
p1=new Panel();
p2=new Panel();
p3=new Panel();
mouseevent=new mouse_event(f);
my_button=new Button("my_button");
my_button2=new Button("my_button2");
my_button3=new Button("my_button3");
my_button.addMouseListener(mouseevent);
my_button2.addMouseListener(mouseevent);
my_button3.addMouseListener(mouseevent);
p1.setLayout(new GridLayout(3,3));
p2.setLayout(new GridLayout(3,3));
p3.setLayout(new GridLayout(3,3));
for(int i=0;i<9;i++){
p1.add(new Button("one"+i));
}
for(int i=0;i<9;i++){
p2.add(new Button("two"+i));
}
for(int i=0;i<9;i++){
p3.add(new Button("three"+i));
}
//p1.setLayout(new FlowLayout(FlowLayout.CENTER,20,20));
//p2.setLayout(new FlowLayout(FlowLayout.CENTER,20,20));
//p3.setLayout(new FlowLayout(FlowLayout.CENTER,20,20));
f.addWindowListener(new mouse_event(f));
f.setSize(400,300);
//f.setLayout(new GridLayout(2,3));
f.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
f.add(p1);
f.add(p2);
f.add(p3);
f.setVisible(true);
//this.add(my_button,BorderLayout.SOUTH);
//this.add(my_button2,BorderLayout.EAST);
//this.add(my_button3,BorderLayout.NORTH);
//this.setLayout(new FlowLayout(FlowLayout.CENTER,20,20));
}
public void destroy(){
}
public void start(){
}
public void stop(){
}
}