-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrameExample.java
More file actions
160 lines (100 loc) · 2.64 KB
/
Copy pathFrameExample.java
File metadata and controls
160 lines (100 loc) · 2.64 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author my
*/
import java.awt.*;
import java.awt.event.*;
class Design extends Frame implements ActionListener{
Label l1,l2,l3;
Button b;
TextField t1,t2;
Design()
{
// Frame f = new Frame("Button Example");
setBackground(Color.red);
b = new Button("Login");
b.setBounds(100,190,100,20);
l1=new Label("First Label.");
l1.setBounds(50,100, 100,30);
l2=new Label("Second Label.");
l2.setBounds(50,150, 100,30);
l3=new Label("Second Label.");
l3.setBounds(500,250, 200,30);
t1=new TextField();
t1.setBounds(170,100, 200,30);
t2=new TextField();
t2.setBounds(170,150, 200,30);
b.addActionListener(this);
b.setBackground(Color.blue);
add(b);
add(l1);
add(l2);
add(t1);
add(t2);
add(l3);
setSize(1000,1000);
setLayout(null);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
// String f_name = t1.getText().toString();
// String l_name = t2.getText().toString();
// String name = f_name + " " + l_name;
// l3.setText(name);
Design1 d1 = new Design1("worker");
d1.setVisible(true);
this.setVisible(false);
}
}
// ===============================
class Design1 extends Frame implements ActionListener{
Label l1,l2,l3;
Button b;
TextField t1,t2;
Design1(String name)
{
b = new Button("Login");
b.setBounds(100,190,100,20);
// l1=new Label("First Label.");
// l1.setBounds(50,100, 100,30);
// l2=new Label("Second Label.");
// l2.setBounds(50,150, 100,30);
l3=new Label("Second Label.");
l3.setBounds(500,250, 200,30);
l3.setText(name);
t1=new TextField();
t1.setBounds(170,100, 200,30);
t2=new TextField();
t2.setBounds(170,150, 200,30);
b.addActionListener(this);
add(b);
// add(l1);
// add(l2);
add(t1);
add(t2);
add(l3);
setSize(1000,1000);
setLayout(null);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
String f_name = t1.getText().toString();
String l_name = t2.getText().toString();
String name = f_name + " " + l_name;
l3.setText(name);
}
}
public class FrameExample
{
public static void main(String args[])
{
Design d = new Design();
}
}