-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswingDemo.java
More file actions
72 lines (60 loc) · 1.94 KB
/
swingDemo.java
File metadata and controls
72 lines (60 loc) · 1.94 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
import javax.swing.*;
import javax.swing.JFrame;
import java.awt.*;
public class swingDemo {
public static void main(String[] args) {
class1 obj = new class1();
}
};
class class1 extends JFrame {
public class1() {
JFrame f = new JFrame("USER FORM");
f.setVisible(true);
f.setSize(800, 550);
f.setLayout(null);
// grid layout allows to select layout ourself
Font Font1 = new Font("Times New Roman", Font.BOLD, 15);
// ADDING REQUIRED LABELS
// LABEL 1
JLabel l0 = new JLabel("ADMIN OR CUSTOMER ?");
l0.setBounds(300, 0, 200, 150);
l0.setFont(Font1);
f.add(l0);
JRadioButton admin = new JRadioButton("Admin");
admin.setBounds(200, 125, 80, 20);
JRadioButton cust = new JRadioButton("Customer");
cust.setBounds(300, 125, 100, 20);
// Setting default state to be customer
cust.setSelected(true);
admin.setFont(Font1);
cust.setFont(Font1);
f.add(admin);
f.add(cust);
// Allowing user to only select admin or customer at a time
ButtonGroup gen = new ButtonGroup();
gen.add(admin);
gen.add(cust);
JLabel l1 = new JLabel("Username :");
l1.setBounds(200, 200, 200, 20);
l1.setFont(Font1);
f.add(l1);
JTextField t1 = new JTextField(20);
t1.setBounds(300, 200, 200, 20);
f.add(t1);
// LABEL 2
JLabel l2 = new JLabel("Password :");
l2.setBounds(200, 300, 200, 20);
l2.setFont(Font1);
f.add(l2);
JTextField t2 = new JTextField(20);
t2.setBounds(300, 300, 200, 20);
f.add(t2);
JButton b = new JButton("SUBMIT");
b.setBounds(400, 400, 100, 50);
f.add(b);
String f1[] = { "Sign In", "Log In" };
JComboBox cb = new JComboBox(f1);
cb.setBounds(200, 400, 100, 50);
f.add(cb);
};
}