-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheventsPage.java
More file actions
92 lines (82 loc) · 2.98 KB
/
eventsPage.java
File metadata and controls
92 lines (82 loc) · 2.98 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
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
public class eventsPage {
private JButton event1;
private JButton event2;
private JButton event3;
private JButton event4;
private JLabel event1_image;
private JLabel event2_image;
private JLabel event3_image;
private JLabel event4_image;
private JLabel event1_name;
private JLabel event2_name;
private JLabel event3_name;
private JLabel event4_name;
private JPanel eventPagePanel;
private JButton backButton;
public eventsPage(JFrame frame) {
event1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
openWebPage("https://www.google.com");
}
});
event2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
openWebPage("https://www.google.com");
}
});
event3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
openWebPage("https://www.google.com");
}
});
event4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
openWebPage("https://www.google.com");
}
});
backButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Switch back to the main menu
frame.setContentPane(new mainMenu(frame).mainMenuPanel);
frame.revalidate(); // Refresh the frame
frame.pack(); // Adjust the frame size to fit the content
}
});
}
public static void main(String[] args) {
// Create a JFrame to hold the eventsPage panel
JFrame frame = new JFrame("Events Page");
frame.setTitle("Events Page");
frame.setSize(800, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create an instance of eventsPage and set it as the content pane
JPanel panel = new eventsPage(frame).getEventsPane(); // Fixed instantiation of the correct class
frame.setContentPane(new eventsPage(frame).getEventsPane());
// Display the frame
frame.setLocationRelativeTo(null); // Center the frame on the screen
frame.setVisible(true);
}
private void openWebPage(String urlString) {
try {
Desktop.getDesktop().browse(new URL(urlString).toURI());
} catch (Exception e) {
e.printStackTrace(); // Print the stack trace for debugging
}
}
private void initComponents() {
// Initialize your components here if not generated by a GUI designer
}
public JPanel getEventsPane() {
return eventPagePanel;
};
}