-
Notifications
You must be signed in to change notification settings - Fork 0
/
FrameApp.java~
175 lines (170 loc) · 4.39 KB
/
FrameApp.java~
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
/**
* This class is frame class of the program.
* @author Eric Tu and Sejin Kwon
* @version 3
* @since June 1 2012
*/
public class FrameApp{
/**
* This is the JFrame of the program.
*/
static JFrame frame = new JFrame();
/**
* The layout for the mainPanel
*/
static CardLayout cardLayout = new CardLayout();
/**
* The mainPanel, which is used to contain the cards.
*/
static JPanel mainPanel;
/**
* String for the INTRO card.
*/
static final String INTRO = "INTRO";
/**
* String for the MAINMENU card.
*/
static final String MAINMENU = "MAINMENU";
/**
* String for the GOODBYE card.
*/
static final String GOODBYE = "GOODBYE";
/**
* String for the LEVELSELECT card.
*/
static final String LEVELSELECT = "LEVELSELECT";
/**
* String for the GAME card.
*/
static final String GAME = "GAME";
/**
* String for the HIGHSCORE card.
*/
static final String HIGHSCORE = "HIGHSCORE";
/**
* String for the HIGHSCORE card.
*/
static final String HIGHSCORELS = "HIGHSCORELS";
/**
* String for the INSTRUCTIONS card.
*/
static final String INSTRUCTIONS1 = "INSTRUCTIONS1";
/**
* String for the INSTRUCTIONS card.
*/
static final String INSTRUCTIONS2 = "INSTRUCTIONS2";
/**
* String for the PAUSE card.
*/
static final String PAUSE = "PAUSE";
/**
* String for the PAUSE card.
*/
static final String COLOURSELECT = "COLOURSELECT";
static final String INTRODUCTION = "INTRODUCTION";
/**
* A Game Object.
*/
public static Game g = new Game();
/**
* A Game Object.
*/
public static ColourSelect cs = new ColourSelect();
/**
* A MainMenu Object.
*/
public static MainMenu mm = new MainMenu();
/**
* A LevelSelect Object.
*/
public static LevelSelect ls = new LevelSelect();
/**
* A LevelSelect Object.
*/
public static Introduction i = new Introduction();
/**
* A GoodBye Object.
*/
public static GoodBye gb = new GoodBye();
/**
* A Pause Object.
*/
public static Pause p = new Pause();
public static Instruction1 in = new Instruction1 ();
public static Instruction2 in2 = new Instruction2 ();
public static ScorePanel s = new ScorePanel ();
public static HighScore hs = new HighScore();
public static HighScoreLevelSelect hsls = new HighScoreLevelSelect ();
/**
* The class constructor.
*
* The mainPanel is initialized and the cards are added onto the panel.
* The mainPanel is updated.
* The mainPanel is added onto the JFrame frame and frame's attributes are set.
*/
public FrameApp(){
frame.setContentPane ( new JLabel (new ImageIcon ("Background.png")));
mainPanel = new JPanel (cardLayout);
Action help = new AbstractAction () {
public void actionPerformed (ActionEvent e)
{
try
{
Runtime.getRuntime ( ).exec ("hh.exe Rainbow Plants.chm");
}
catch (IOException easasads)
{
}
}
};
mainPanel.getInputMap ().put (KeyStroke.getKeyStroke ("H"), "Help");
mainPanel.getActionMap ().put ("Help", help);
mainPanel.add (i, INTRODUCTION);
mainPanel.add ( mm,MAINMENU);
mainPanel.add ( ls,LEVELSELECT);
mainPanel.add ( gb,GOODBYE);
mainPanel.add (cs, COLOURSELECT);
mainPanel.add(g,GAME);
mainPanel.add( p, PAUSE);
mainPanel.add(hs,HIGHSCORE);
mainPanel.add (in, INSTRUCTIONS1);
mainPanel.add (in2, INSTRUCTIONS2);
mainPanel.add(hsls,HIGHSCORELS);
mainPanel.setPreferredSize(new Dimension (600,600));
mainPanel.updateUI();
mainPanel.setOpaque(false);
i.setOpaque (false);
mm.setOpaque (false);
ls.setOpaque (false);
cs.setOpaque (false);
p.setOpaque (false);
s.setOpaque (false);
gb.setOpaque (false);
in.setOpaque (false);
in2.setOpaque (false);
hsls.setOpaque (false);
frame.setLayout(new FlowLayout());
frame.add(mainPanel);
frame.setTitle("Rainbow Plants");
frame.setSize(840,600);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
frame.setResizable (false);
i.start ();
}
/**
* The main method.
*
* An instance of FrameApp is created.
*
* @param argv Arguments for the main method.
*/
public static void main (String argv []){
new FrameApp();
HighScore.loadFile();
}
}