-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrderNoteMenu.java
More file actions
139 lines (126 loc) · 5.01 KB
/
OrderNoteMenu.java
File metadata and controls
139 lines (126 loc) · 5.01 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
// Jason Jasper
// David Martin-Vaquero
// Jared Mclaren
// Regine Villongco
// Chemen Wong
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
/**
* IS 380 Final Project - Restaurant Point of Sale program.
* @author Jason Jasper, David Martin-Vaquero, Jared Mclaren, Regine Villongco, Chemen Wong
* @version 0.1.0
*
* This is the OrderNote GUI component. This will add a text note (special instructions) to an existing order.
* This does not check to make sure there is an active order first, that is done by OrderMenu. It will throw
* an exception if a note is missing.
*
*/
public class OrderNoteMenu extends JFrame {
private int tableNumber;
/**
Constructor for order note menu.
@param A table number.
*/
public OrderNoteMenu(int tableNum) {
tableNumber = tableNum;
initComponents();
this.setTitle("Table "+tableNumber+ " Add a Note to the Order.");
try {
orderNoteArea.setText(RestaurantPOS.tableArray[tableNumber-1].getOrderNote());
}
catch (Exception e) {
System.out.println("ERROR RETRIEVING ORDER NOTE!!\n" + e.getMessage());
}
}
/**
Method for cancel button's action.
@param ActionEvent object generated.
*/
private void cancelButtonActionPerformed(ActionEvent e) {
this.dispose();
}
/**
Method for ok button's action.
@param ActionEvent object generated.
*/
private void okButtonActionPerformed(ActionEvent e) {
String orderNote = orderNoteArea.getText();
RestaurantPOS.tableArray[tableNumber-1].setOrderNote(orderNote);
this.dispose();
}
/**
Method for creating panels, text areas, and buttons.
*/
private void initComponents() {
dialogPane = new JPanel();
contentPanel = new JPanel();
scrollPane1 = new JScrollPane();
orderNoteArea = new JTextArea();
buttonBar = new JPanel();
okButton = new JButton();
cancelButton = new JButton();
//======== this ========
setTitle("Add Note to Order");
var contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
//======== dialogPane ========
{
dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
dialogPane.setLayout(new BorderLayout());
//======== contentPanel ========
{
contentPanel.setLayout(new BorderLayout());
//======== scrollPane1 ========
{
scrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
//---- orderNoteArea ----
orderNoteArea.setFont(new Font("Arial", Font.PLAIN, 13));
orderNoteArea.setLineWrap(true);
orderNoteArea.setWrapStyleWord(true);
scrollPane1.setViewportView(orderNoteArea);
}
// Add to content panel.
contentPanel.add(scrollPane1, BorderLayout.CENTER);
}
// Add panel to dialog pane.
dialogPane.add(contentPanel, BorderLayout.CENTER);
//======== buttonBar ========
{
buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
buttonBar.setLayout(new GridBagLayout());
((GridBagLayout)buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80};
((GridBagLayout)buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0};
//---- okButton ----
okButton.setText("OK");
okButton.setFont(new Font("Tahoma", Font.PLAIN, 16));
okButton.addActionListener(e -> okButtonActionPerformed(e));
buttonBar.add(okButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
//---- cancelButton ----
cancelButton.setText("Cancel");
cancelButton.setFont(new Font("Tahoma", Font.PLAIN, 16));
cancelButton.addActionListener(e -> cancelButtonActionPerformed(e));
buttonBar.add(cancelButton, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 0), 0, 0));
}
// Add buttons to dialog pane.
dialogPane.add(buttonBar, BorderLayout.SOUTH);
}
// Add to content pane.
contentPane.add(dialogPane, BorderLayout.CENTER);
setSize(400, 375);
setLocationRelativeTo(getOwner());
}
private JPanel dialogPane;
private JPanel contentPanel;
private JScrollPane scrollPane1;
private JTextArea orderNoteArea;
private JPanel buttonBar;
private JButton okButton;
private JButton cancelButton;
}