-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframe.java
More file actions
116 lines (94 loc) · 3.81 KB
/
Copy pathframe.java
File metadata and controls
116 lines (94 loc) · 3.81 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
package project;
import java.awt.Button;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.concurrent.CountDownLatch;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;
class Myframe extends JFrame{
static boolean admn = false;
JFrame frame;
static CountDownLatch latch = new CountDownLatch(1);
Myframe(){
admn=false;
// Create a JFrame
new JFrame();
latch = new CountDownLatch(1);
setTitle("User and Admin Frame");
getContentPane().setBackground(new Color(173, 216, 230));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setSize(screenSize);
Color g = new Color(255,0,0);
JPanel mainPanel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(20, 20, 20, 20); // Add padding
// Create the User label
JLabel userLabel = new JLabel("I Am Here To Learn!");
userLabel.setForeground(Color.BLACK); // Set label text color to black
userLabel.setFont(new Font("Serif", Font.ITALIC, 35)); // Increase font size
// Create the User button
JButton userButton = new JButton("User");
userButton.setBackground(new Color(0, 51, 102)); // Dark blue background
userButton.setForeground(Color.WHITE); // Set button text color to white
userButton.setFont(new Font("Arial", Font.PLAIN, 24)); // Increase font size
// Add action listener to the User button
// Create the Admin label
JLabel adminLabel = new JLabel("I Am Here To Contribute !");
adminLabel.setForeground(Color.BLACK); // Set label text color to black
adminLabel.setFont(new Font("Serif", Font.ITALIC, 35)); // Increase font size
// Create the Admin button
JButton adminButton = new JButton("Admin");
adminButton.setBackground(new Color(0, 51, 102)); // Dark blue background
adminButton.setForeground(Color.WHITE); // Set button text color to white
adminButton.setFont(new Font("Arial", Font.PLAIN, 24)); // Increase font size
// Add the User label and button to the main panel
gbc.gridx = 0;
gbc.gridy = 0;
mainPanel.add(userLabel, gbc);
gbc.gridy = 1;
mainPanel.add(userButton, gbc);
// Add the Admin label and button to the main panel
gbc.gridy = 2;
mainPanel.add(adminLabel, gbc);
gbc.gridy = 3;
mainPanel.add(adminButton, gbc);
LineBorder lb = new LineBorder(new Color(15, 8, 61),5);
mainPanel.setBorder(lb);
mainPanel.setBackground(new Color(202, 206, 217));
// Add the main panel to the frame
add(mainPanel);
// Center the frame on the screen
setLocationRelativeTo(null);
ActionListener button1Listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
admn=true;
latch.countDown();
setVisible(false);
}
};
ActionListener button2Listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
latch.countDown();
setVisible(false);
}
};
adminButton.addActionListener(button1Listener);
userButton.addActionListener(button2Listener);
setVisible(true);
try {
latch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}}