-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHome.java
More file actions
126 lines (107 loc) · 3.45 KB
/
Copy pathHome.java
File metadata and controls
126 lines (107 loc) · 3.45 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
import javax.swing.*;
import java.awt.*;
import java.sql.*;
class Home extends JFrame {
Home(String username) {
double balance = 0.0;
Font f = new Font("Futura", Font.BOLD, 40);
Font f2 = new Font("Calibri", Font.PLAIN, 22);
JLabel title = new JLabel("Welcome " + username, JLabel.CENTER);
JLabel balanceLabel = new JLabel("Balance: ₹0.00", JLabel.CENTER);
JButton b1 = new JButton("Deposit");
JButton b2 = new JButton("Withdraw");
JButton b3 = new JButton("Profile Settings");
JButton b4 = new JButton("Transfer");
JButton b5 = new JButton("Passbook");
JButton b6 = new JButton("Logout");
title.setFont(f);
balanceLabel.setFont(f2);
b1.setFont(f2);
b2.setFont(f2);
b3.setFont(f2);
b4.setFont(f2);
b5.setFont(f2);
b6.setFont(f2);
Container c = getContentPane();
c.setLayout(null);
title.setBounds(100, 30, 600, 50);
balanceLabel.setBounds(100, 100, 600, 30);
b1.setBounds(100, 150, 200, 40);
b2.setBounds(400, 150, 200, 40);
b3.setBounds(100, 220, 200, 40);
b4.setBounds(400, 220, 200, 40);
b5.setBounds(100, 290, 200, 40);
b6.setBounds(400, 290, 200, 40);
c.add(title);
c.add(balanceLabel);
c.add(b1);
c.add(b2);
c.add(b3);
c.add(b4);
c.add(b5);
c.add(b6);
b5.addActionListener(
a ->
{
new Passbook(username);
dispose();
}
);
b3.addActionListener(
a ->
{
new Profile(username);
dispose();
}
);
b4.addActionListener(
a ->
{
new Transfer(username);
dispose();
}
);
b1.addActionListener(
a -> {
new Deposit(username);
dispose();
}
);
b2.addActionListener(
a ->
{
new Withdraw(username);
dispose();
}
);
b6.addActionListener(
a ->
{
new Landing();
dispose();
}
);
String url = "jdbc:mysql://localhost:3306/3dec";
try (Connection con = DriverManager.getConnection(url, "root", "Mehta@17")) {
String sql = "select balance from users where username=?";
try (PreparedStatement pst = con.prepareStatement(sql)) {
pst.setString(1, username);
ResultSet rs = pst.executeQuery();
if (rs.next()) {
balance = rs.getDouble("balance");
}
balanceLabel.setText("Balance: ₹" + balance);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
}
setVisible(true);
setSize(800, 550);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle("Home");
}
public static void main(String[] args) {
new Home("Swayam");
}
}