-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenu.java
More file actions
111 lines (99 loc) · 3.52 KB
/
MainMenu.java
File metadata and controls
111 lines (99 loc) · 3.52 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
// Jason Jasper
// David Martin-Vaquero
// Jared Mclaren
// Regine Villongco
// Chemen Wong
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import javax.swing.*;
/**
* 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 Main Menu GUI component. There are only 3 options, the Order screen, the Reports screen, and Exit.
* Order opens up the main portion of this app where the user can Add, Subtract, Comp, and add Notes to orders.
* Reports opens up a Report window (not yet implemented)
* Exit closes the entire App.
*
*/
public class MainMenu extends JFrame {
public JFrame orderWindow;
public static DecimalFormat df2 = new DecimalFormat("#0.00");
public MainMenu() {
initComponents();
//Commenting this out to fix color coded button bug - Not working
orderWindow = new OrderMenu();
orderWindow.setVisible(false);
}
/**
Method for exit button's action.
@param ActionEvent object generated.
*/
private void exitButtonActionPerformed(ActionEvent e) {
System.exit(0);
}
/**
Method for order button's action.
@param ActionEvent object generated.
*/
private void orderButtonActionPerformed(ActionEvent e) {
orderWindow.setVisible(true);
this.setVisible(false);
}
/**
Method for report button's action. I wish we had more time to do something more with this, but we don't.
@param ActionEvent object generated.
*/
private void reportButtonActionPerformed(ActionEvent e) {
double totalRevenue = Order.totalSales + Order.totalTax;
JOptionPane.showMessageDialog(null, "Total sales: $"+ df2.format(Order.totalSales)
+ "\nTotal Tax: $"+ df2.format(Order.totalTax) +"\nTotal Revenue: $"+df2.format(totalRevenue)
+ "\nTotal Tips: $"+ df2.format(Order.totalTips), "Sales Report", JOptionPane.INFORMATION_MESSAGE);
}
/**
Method to hide main menu.
*/
public void hideMain() {
this.setVisible(false);
}
/**
Method to show main menu.
*/
public void showMain() {
this.setVisible(true);
}
/**
Method to create buttons.
*/
private void initComponents() {
orderButton = new JButton();
reportButton = new JButton();
exitButton = new JButton();
//======== this ========
setTitle("Main Menu");
var contentPane = getContentPane();
contentPane.setLayout(new GridLayout(3, 1, 10, 10));
//---- orderButton ----
orderButton.setText("Orders");
orderButton.setFont(new Font("Arial Black", Font.BOLD, 26));
orderButton.addActionListener(e -> orderButtonActionPerformed(e));
contentPane.add(orderButton);
//---- reportButton ----
reportButton.setText("Reports");
reportButton.setFont(new Font("Arial Black", Font.BOLD, 26));
reportButton.addActionListener(e -> reportButtonActionPerformed(e));
contentPane.add(reportButton);
//---- exitButton ----
exitButton.setText("Exit");
exitButton.setFont(exitButton.getFont().deriveFont(exitButton.getFont().getSize() + 10f));
exitButton.addActionListener(e -> exitButtonActionPerformed(e));
contentPane.add(exitButton);
setSize(605, 435);
setLocationRelativeTo(getOwner());
}
private JButton orderButton;
private JButton reportButton;
private JButton exitButton;
}