-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.java
More file actions
112 lines (93 loc) · 3.81 KB
/
Copy pathTransaction.java
File metadata and controls
112 lines (93 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
import javax.swing.*;
import java.awt.*;
public class Transaction extends JFrame {
JButton deposit, cashWithdrawal, fastCash, miniStatement, balanceEnquiry, exitButton;
String cardNumber;
// ✅ Constructor that accepts cardNumber
public Transaction(String cardNumber) {
this.cardNumber = cardNumber;
setTitle("Transactions");
setLayout(null);
// Background image
ImageIcon i1 = new ImageIcon("C:/Users/OM DAHIWALE/Desktop/Bank Management System/lib/atmmachine.jpg");
Image i2 = i1.getImage().getScaledInstance(900, 900, Image.SCALE_DEFAULT);
ImageIcon i3 = new ImageIcon(i2);
JLabel background = new JLabel(i3);
background.setBounds(0, 0, 900, 900);
add(background);
// Heading
JLabel heading = new JLabel("Please select your Transaction");
heading.setForeground(Color.WHITE);
heading.setFont(new Font("Arial", Font.BOLD, 18));
heading.setHorizontalAlignment(SwingConstants.CENTER);
heading.setBounds(250, 250, 400, 30);
background.add(heading);
// Initialize buttons
deposit = new JButton("Deposit");
cashWithdrawal = new JButton("Cash Withdrawal");
fastCash = new JButton("Fast Cash");
miniStatement = new JButton("Mini Statement");
balanceEnquiry = new JButton("Balance Enquiry");
exitButton = new JButton("Exit"); // ✅ Exit Button
JButton[] buttons = {deposit, cashWithdrawal, fastCash, miniStatement};
int btnWidth = 180, btnHeight = 35;
int startX = 270, startY = 320, xGap = 200, yGap = 60;
int k = 0;
for (int row = 0; row < 2; row++) {
for (int col = 0; col < 2; col++) {
JButton btn = buttons[k++];
btn.setBounds(startX + col * xGap, startY + row * yGap, btnWidth, btnHeight);
btn.setBackground(new Color(0, 102, 204));
btn.setForeground(Color.WHITE);
btn.setFont(new Font("Arial", Font.BOLD, 14));
btn.setFocusPainted(false);
background.add(btn);
}
}
// Balance Enquiry button
balanceEnquiry.setBounds(360, 440, 160, 35);
balanceEnquiry.setBackground(new Color(0, 102, 204));
balanceEnquiry.setForeground(Color.WHITE);
balanceEnquiry.setFont(new Font("Arial", Font.BOLD, 14));
background.add(balanceEnquiry);
// ✅ Exit Button next to Balance Enquiry
exitButton.setBounds(530, 440, 100, 35); // 360 + 160 + 10 = 530
exitButton.setBackground(Color.RED);
exitButton.setForeground(Color.WHITE);
exitButton.setFont(new Font("Arial", Font.BOLD, 14));
exitButton.setFocusPainted(false);
background.add(exitButton);
// ✅ Add action listeners that pass cardNumber
deposit.addActionListener(e -> {
setVisible(false);
new Deposit(cardNumber);
});
cashWithdrawal.addActionListener(e -> {
setVisible(false);
new CashWithdrawal(cardNumber);
});
fastCash.addActionListener(e -> {
setVisible(false);
new FastCash(cardNumber);
});
miniStatement.addActionListener(e -> {
new MiniStatement(cardNumber);
});
balanceEnquiry.addActionListener(e -> {
new BalanceEnquiry(cardNumber);
});
// ✅ Exit button redirects to Login page
exitButton.addActionListener(e -> {
setVisible(false);
new Login(); // Back to Login page
});
// Frame setup
setSize(900, 900);
setLocation(300, 0);
setVisible(true);
}
// For testing only
public static void main(String[] args) {
new Transaction("1234567890123456");
}
}