-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewScreen.java
More file actions
58 lines (46 loc) · 1.77 KB
/
viewScreen.java
File metadata and controls
58 lines (46 loc) · 1.77 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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.NumberFormat;
import java.sql.*;
public class viewScreen {
private JFrame frame;
private JPanel panel;
private JLabel label;
viewScreen(){
String currUser = ATM.name.getText();
try{
Statement myStat = database.getConn().createStatement();
String query = "SELECT * FROM mydb.atm_data WHERE Name='"+currUser+"'";
ResultSet myRs = myStat.executeQuery(query);
if(myRs.next()){
Float bal = myRs.getFloat("Balance");
NumberFormat myFormat = NumberFormat.getInstance();
myFormat.setGroupingUsed(true);
label = new JLabel(" Welcome " + currUser+ ", Your current account balance is: $"+ myFormat.format(bal));
}
}
catch(Exception e){
e.printStackTrace();
}
JButton back = new JButton("BACK");
back.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
frame.dispose();
new menuScreen();
}
});
frame = new JFrame("VIEW BALANCE");
panel = new JPanel();
JPanel tpanel = new JPanel();
frame.setSize(600,300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setLocationRelativeTo(null);
frame.getContentPane().setBackground(Color.LIGHT_GRAY);
frame.getContentPane().add(tpanel, BorderLayout.NORTH);
frame.getContentPane().add(panel, BorderLayout.CENTER);
tpanel.add(label);
panel.add(back);
}
}