-
Notifications
You must be signed in to change notification settings - Fork 1
/
CreditCardForm.java
67 lines (57 loc) · 1.94 KB
/
CreditCardForm.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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class CreditCardForm extends JFrame implements ActionListener {
private JLabel cardNumberLabel;
private JTextField cardNumberField;
private JLabel nameLabel;
private JTextField nameField;
private JLabel expiryLabel;
private JTextField expiryField;
private JLabel cvvLabel;
private JTextField cvvField;
private JButton submitButton;
public CreditCardForm() {
setTitle("Credit Card Form");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(5, 2));
// display the form in the center of the screen
setLocationRelativeTo(null);
cardNumberLabel = new JLabel("Card Number:");
cardNumberField = new JTextField(16);
nameLabel = new JLabel("Card Holder's Name:");
nameField = new JTextField(20);
expiryLabel = new JLabel("Expiry Date:");
expiryField = new JTextField(4);
cvvLabel = new JLabel("CVV:");
cvvField = new JTextField(3);
submitButton = new JButton("Submit");
add(cardNumberLabel);
add(cardNumberField);
add(nameLabel);
add(nameField);
add(expiryLabel);
add(expiryField);
add(cvvLabel);
add(cvvField);
add(new JLabel(""));
add(submitButton);
submitButton.addActionListener(this);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == submitButton){
String ccinformation = "|"+nameField.getText()+"|"+cardNumberField.getText()+"|"+expiryField.getText()+"|"+cvvField.getText();
String encryptedcc = ccinformation;
System.out.println(encryptedcc);
// String encryptedcc = encryptStringWithPublicKey("Public key" , ccinformation);
// send encryptedcc to the server
this.dispose();
new BillingForm();
}
}
public static void main(String[] args) {
new CreditCardForm();
}
}