forked from sanjana091001/bus_booking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loginbtn.java
71 lines (66 loc) · 1.53 KB
/
loginbtn.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
package bus_booking;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class loginbtn extends JFrame implements ActionListener{
JButton addBtn, modifyBtn;
JLabel desc;
JTextField n;
loginbtn()
{
setTitle("Booking");
getContentPane().setBackground(Color.WHITE);
setBackground(Color.CYAN);
getContentPane().setForeground(Color.WHITE);
getContentPane().setLayout(new FlowLayout());
JLabel label = new JLabel("Booking");
label.setFont(new Font("SANS_SERIF", Font.BOLD, 20));
label.setForeground(Color.BLACK);
getContentPane().add(label);
setBounds(400, 200, 400, 400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
desc=new JLabel("User id");
n=new JTextField("User1", 5);
JButton addBtn = new JButton("Add new user");
JButton modifyBtn=new JButton("Modify details");
addBtn.addActionListener(this);
modifyBtn.addActionListener(this);
add(addBtn);
add(modifyBtn);
setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
user obj=new user("user4", "pass4");
if(ae.getSource() == addBtn)
{
try
{
obj.addDetails();
}
catch(Exception e)
{
e.printStackTrace();
}
repaint();
}
else if(ae.getSource()==modifyBtn)
{
try
{
obj.modifyDetails("newPass4");
}
catch(Exception e)
{
e.printStackTrace();
}
repaint();
}
}
}