-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathWelcomeScreen.java
More file actions
75 lines (61 loc) · 2.03 KB
/
WelcomeScreen.java
File metadata and controls
75 lines (61 loc) · 2.03 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
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.SwingConstants;
import java.awt.Color;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class WelcomeScreen extends JFrame {
private String userid;
private JPanel contentPane;
private void startGameOne(){
GameOne gameOne = new GameOne();
gameOne.setVisible(true);
}
public WelcomeScreen(String userid) {
setExtendedState(JFrame.MAXIMIZED_BOTH);
this.userid = userid; // Local Userid is set to this.userid (Instance Variable)
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel msg = new JLabel("Welcome "+userid);
msg.setForeground(Color.RED);
msg.setHorizontalAlignment(SwingConstants.CENTER);
msg.setFont(new Font("Lucida Grande", Font.BOLD, 18));
msg.setBounds(56, 69, 153, 43);
contentPane.add(msg);
JMenuBar menuBar = new JMenuBar();
this.setJMenuBar(menuBar); // add menubar in frame
JMenu mnFile = new JMenu("File");
menuBar.add(mnFile); // add menu in menubar
JMenuItem mntmGame = new JMenuItem("Game 1");
mntmGame.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
startGameOne();
}
});
mnFile.add(mntmGame); // add menuitem in menu
JMenuItem mntmGame_1 = new JMenuItem("Game 2");
mntmGame_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
mnFile.add(mntmGame_1);
JMenuItem mntmExit = new JMenuItem("Exit");
mnFile.add(mntmExit);
JMenuBar menuBar_1 = new JMenuBar();
menuBar.add(menuBar_1);
//menuBar.setBounds(90, 146, 132, 22);
//contentPane.add(menuBar);
}
}