-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPayment.java
More file actions
181 lines (125 loc) · 4.92 KB
/
Payment.java
File metadata and controls
181 lines (125 loc) · 4.92 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import java.awt.Color;
import java.awt.Font;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Payment extends JFrame implements ActionListener {
JLabel titleLabel;
JTextField nameField,cardField,validField,cvvField;
JButton confirmButton,exitButton,backButton;
public Payment() {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(700, 450);
this.setLocationRelativeTo(null);
this.setResizable(false);
this.setLayout(null);
titleLabel = new JLabel("Complete Your Payment Total Ammount: " +TotalCost() );
titleLabel.setBounds(110, 40, 1000, 50);
titleLabel.setFont(new Font("Segoe UI Black",Font.PLAIN,22));
this.add(titleLabel);
titleLabel = new JLabel("We Accept Only");
titleLabel.setBounds(130, 100, 200, 50);
titleLabel.setFont(new Font("Segoe UI SemiBold",Font.PLAIN,20));
this.add(titleLabel);
titleLabel = new JLabel();
titleLabel.setIcon(new ImageIcon(getClass().getResource("Storage/MasterCard.png")));
titleLabel.setBounds(280,100,100,50);
this.add(titleLabel);
titleLabel = new JLabel();
titleLabel.setIcon(new ImageIcon(getClass().getResource("Storage/VisaCard.png")));
titleLabel.setBounds(360,100,100,50);
this.add(titleLabel);
titleLabel = new JLabel("Card Details");
titleLabel.setBounds(130, 150, 200, 50);
titleLabel.setFont(new Font("Segoe UI SemiBold",Font.PLAIN,20));
this.add(titleLabel);
titleLabel = new JLabel("Name On Card :");
titleLabel.setBounds(140, 190, 200, 50);
titleLabel.setFont(new Font("Segoe UI",Font.PLAIN,18));
this.add(titleLabel);
nameField = new JTextField();
nameField.setBounds(275, 200, 300, 30);
nameField.setFont(new Font("Segoe UI",Font.PLAIN,18));
this.add(nameField);
titleLabel = new JLabel("Card Number :");
titleLabel.setBounds(140, 230, 200, 50);
titleLabel.setFont(new Font("Segoe UI",Font.PLAIN,18));
this.add(titleLabel);
cardField = new JTextField();
cardField.setBounds(275, 240, 300, 30);
cardField.setFont(new Font("Segoe UI",Font.PLAIN,18));
this.add(cardField);
titleLabel = new JLabel("Valid On :");
titleLabel.setBounds(140, 270, 120, 50);
titleLabel.setFont(new Font("Segoe UI",Font.PLAIN,18));
this.add(titleLabel);
validField = new JTextField();
validField.setBounds(230, 280, 120, 30);
validField.setFont(new Font("Segoe UI",Font.PLAIN,18));
this.add(validField);
titleLabel = new JLabel("CVV Code :");
titleLabel.setBounds(365, 270, 120, 50);
titleLabel.setFont(new Font("Segoe UI",Font.PLAIN,18));
this.add(titleLabel);
cvvField = new JTextField();
cvvField.setBounds(460, 280, 120, 30);
cvvField.setFont(new Font("Segoe UI",Font.PLAIN,18));
this.add(cvvField);
confirmButton = new JButton("Confirm Payment");
confirmButton.setBounds(330, 330, 250, 50);
confirmButton.setFocusable(false);
confirmButton.setFont(new Font("Segoe UI SemiBold",Font.PLAIN,25));
confirmButton.setForeground(Color.white);
confirmButton.setBackground(Color.decode("#2E75B6"));
this.add(confirmButton);
exitButton = new JButton("EXIT");
exitButton.setBounds(140, 330, 140, 50);
exitButton.setFocusable(false);
exitButton.setFont(new Font("Segoe UI SemiBold",Font.PLAIN,25));
exitButton.setForeground(Color.white);
exitButton.setBackground(Color.decode("#C00000"));
this.add(exitButton);
backButton = new JButton("<<Back");
backButton.setBounds(0, 0, 150, 50);
backButton.setFocusable(false);
backButton.setFont(new Font("Segoe UI SemiBold",Font.PLAIN,25));
backButton.setForeground(Color.white);
backButton.setBackground(Color.decode("#2E75B6"));
this.add(backButton);
confirmButton.addActionListener(this);
exitButton.addActionListener(this);
backButton.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource()==exitButton) {
System.exit(0);
}
if (e.getSource() == backButton)
{
dispose();
Login2 Login2 = new Login2();
Login2.setVisible(true);
}
if(e.getSource()==confirmButton) {
String name = nameField.getText();
String card = cardField.getText();
String valid = validField.getText();
String cvv = cvvField.getText();
if (name.isEmpty()||card.isEmpty()||valid.isEmpty()||cvv.isEmpty()) {
JOptionPane.showMessageDialog(null, "Please fill all of the fields.", "Warning!",
JOptionPane.WARNING_MESSAGE);
}
else {
setVisible(false);
PaySuccess frame = new PaySuccess();
frame.setVisible(true);
}
}
}
public static void main (String [] args) {
Payment payment = new Payment();
payment.setVisible(true);
}
}