-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBillingForm.java
More file actions
72 lines (61 loc) · 2.14 KB
/
BillingForm.java
File metadata and controls
72 lines (61 loc) · 2.14 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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class BillingForm extends JFrame implements ActionListener {
private JLabel countryLabel;
private JTextField countryField;
private JLabel stateLabel;
private JTextField stateField;
private JLabel cityLabel;
private JTextField cityField;
private JLabel addressLabel;
private JTextField addressField;
private JLabel zipLabel;
private JTextField zipField;
private JButton submitButton;
public BillingForm() {
setTitle("Billing Address Form");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(6, 2));
// display the form in the center of the screen
setLocationRelativeTo(null);
countryLabel = new JLabel("Country:");
countryField = new JTextField(16);
stateLabel = new JLabel("State:");
stateField = new JTextField(20);
addressLabel = new JLabel("Address:");
addressField = new JTextField(20);
cityLabel = new JLabel("City:");
cityField = new JTextField(15);
zipLabel = new JLabel("Zip:");
zipField = new JTextField(15);
submitButton = new JButton("Submit");
add(countryLabel);
add(countryField);
add(stateLabel);
add(stateField);
add(addressLabel);
add(addressField);
add(cityLabel);
add(cityField);
add(zipLabel);
add(zipField);
add(new JLabel(""));
add(submitButton);
submitButton.addActionListener(this);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == submitButton){
String billinginformation = "Country"+countryField.getText() + " City:"+cityField.getText()
+" Address:"+addressField.getText() + " State:"+stateField.getText()
+" Zip:"+zipField.getText();
System.out.print(billinginformation);
// Display a confirmation message
JOptionPane.showMessageDialog(null,
"Your order has been submitted. Thank you " + Client.name + "!");
this.dispose();
}
}
}