-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainMenu.java
More file actions
82 lines (75 loc) · 3.06 KB
/
mainMenu.java
File metadata and controls
82 lines (75 loc) · 3.06 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
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class mainMenu {
public JPanel mainMenuPanel;
private JButton eventsPage;
private JButton bunkoMeterButton;
private JButton addAnEventButton;
private JButton bridgeUButton;
private JButton collectDeliveryButton;
private JFrame frame; // Reference to the frame
public mainMenu(JFrame frame) {
this.frame = frame;
// Initialize buttons with ActionListeners
eventsPage.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Switch to eventsPage
switchToPage(new eventsPage(frame).getEventsPane()); // You need to create EventsPage class
}
});
bunkoMeterButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Switch to bunkoMeterPage
switchToPage(new BunkoMeterPage(frame).getBunkoMeterPanel()); // You need to create BunkoMeterPage class
}
});
addAnEventButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
frame.setContentPane(new addAnEvent(frame).getAddAnEventPanel()); // Switch to Add Event page
frame.revalidate();
frame.pack();
}
});
bridgeUButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Redirect to the AlmaConnect website
try {
Desktop.getDesktop().browse(new URI("https://www.almaconnect.com/")); // Open the website
} catch (IOException | URISyntaxException ex) {
ex.printStackTrace(); // Handle exceptions appropriately
}
}
});
collectDeliveryButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Switch to orderDeliveryPage
switchToPage(new orderDelivery(frame).getOrderDeliveryPane()); // Pass the frame reference
}
});
}
private void switchToPage(JPanel newPage) {
frame.setContentPane(newPage); // Set the new page as content pane
frame.revalidate(); // Refresh the frame
frame.pack(); // Adjust the frame size to fit the new content
}
public static void main(String[] args) {
JFrame frame = new JFrame("Main Menu");
frame.setTitle("WorkSpace");
frame.setSize(450, 800);
frame.setBounds(600, 200, 450, 800);
frame.setContentPane(new mainMenu(frame).mainMenuPanel); // Pass the frame reference
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}