-
Notifications
You must be signed in to change notification settings - Fork 0
/
debitGUI.java
61 lines (50 loc) · 1.9 KB
/
debitGUI.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
package park;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class debitGUI extends JFrame implements ActionListener {
// GUI components
private JLabel cardNumberLabel, expiryDateLabel, cvvLabel;
private JTextField cardNumberField, expiryDateField, cvvField;
private JButton payButton;
public debitGUI() {
// Set up the window
super("Debit Card Payment");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400, 200);
// Create the GUI components
cardNumberLabel = new JLabel("Debit Card Number:");
cardNumberField = new JTextField(20);
expiryDateLabel = new JLabel("Expiry Date (MM/YY):");
expiryDateField = new JTextField(5);
cvvLabel = new JLabel("CVV:");
cvvField = new JTextField(3);
payButton = new JButton("Pay");
payButton.addActionListener(this);
// Create a layout for the components
JPanel panel = new JPanel(new GridLayout(4, 2));
panel.add(cardNumberLabel);
panel.add(cardNumberField);
panel.add(expiryDateLabel);
panel.add(expiryDateField);
panel.add(cvvLabel);
panel.add(cvvField);
panel.add(new JLabel());
panel.add(payButton);
// Add the panel to the window
setContentPane(panel);
setVisible(true);
}
// Handle the pay button click event
public void actionPerformed(ActionEvent e) {
// Get the card details from the text fields
String cardNumber = cardNumberField.getText();
String expiryDate = expiryDateField.getText();
String cvv = cvvField.getText();
// Process the payment using the card details
// TODO: implement payment processing logic here
// Show a confirmation message
JOptionPane.showMessageDialog(this, "Payment processed successfully!");
dispose();
}
}