/
IntroWindow
143 lines (96 loc) · 3.81 KB
/
IntroWindow
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
140
141
142
143
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Toolkit;
import java.net.URL;
public class IntroWindow extends JPanel
{
private JLabel infoLabel; //declares a label
private JPanel infoPanel;
private JPanel imgPanel; //declares a panel
private JLabel imgLabel;
private JPanel buttonPanel; // declares a panel
private JButton startButton;
//
// Constructor
//
public IntroWindow()
{
// set this panel to a grid layout and change its color
// setLayout(new GridLayout(0,1,0,1));
setBackground(Color.black);
// initialize 3 panels, set their colors and add them to the main panel
//
// Button Panel
//
buttonPanel= new JPanel();
buttonPanel.setBackground(Color.black);
startButton = new JButton("START");// closes current window and starts a new game from the instructions window
buttonPanel.add(startButton);
//
// First Panel
//
infoPanel = new JPanel();
infoPanel.setLayout(new BoxLayout(infoPanel, BoxLayout.Y_AXIS));
//setLayout(new GridLayout(0,1,0,0));
infoPanel.setBackground(Color.black);
infoLabel = new JLabel(""); //instantiates new JLabel
infoLabel.setText("<html><div style=\"text-align: center;\">"+"Jack Sparrow Saves The World...Or Not"+"</html>");
infoLabel.setFont(new Font("Times New Roman", Font.PLAIN, 40));
infoLabel.setForeground(Color.WHITE);
infoPanel.add(infoLabel); //adds this new JLabel
Box.Filler cFill = new Box.Filler(new Dimension(0,19),
new Dimension(0,19),
new Dimension(0,19));
infoPanel.add(cFill);
imgLabel = new JLabel(new ImageIcon("intro.jpg"));
infoPanel.add(imgLabel);
//startButton = new JButton("START");
infoPanel.add(buttonPanel);
add(infoPanel);
// Image Panel
//
imgPanel = new JPanel();
imgPanel.setBackground(Color.white);
// add(imgPanel);
}
/* infoPanel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.VERTICAL;
//setLayout(new GridLayout(0,1,0,0));
infoPanel.setBackground(Color.black);
infoLabel = new JLabel(""); //instantiates new JLabel
infoLabel.setText("<html><div style=\"text-align: left;\">"+"Jack Sparrow Saves The World...Or Not"+"</html>");
infoLabel.setFont(new Font("Times New Roman", Font.PLAIN, 40));
infoLabel.setForeground(Color.WHITE);
c.anchor=(GridBagConstraints.PAGE_START);
infoPanel.add(infoLabel,c); //adds this new JLabel
imgLabel = new JLabel(new ImageIcon("intro.jpg"));
c.anchor=(GridBagConstraints.CENTER);
infoPanel.add(imgLabel,c);
add(infoPanel);
*/
/*
private class ButtonListener implements ActionListener {
public void actionPerformed (ActionEvent event)
{
//quit button was pressed
if (event.getSource() == quitButton) System.exit(0);
}
}
*/
public static void main(String [] args){
JFrame frame = new JFrame ("Wah, wah, waaaahh....");
// creates a new frame
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); // makes a functional exit operation
JPanel pane = new JPanel(new GridBagLayout());
pane.setBackground(Color.black);
// adding the tabs which have panels to the tabbed panel
pane.add (new IntroWindow());
frame.getContentPane().add(pane); // adding the pane to the frame
frame.pack(); // unpacking what we need
frame.setSize(950,650); //sets the size after unpacking
frame.setResizable(false); //frame can no longer can be resized
frame.setVisible(true); // make the frame/everything? visible
}
}