What Will Be Accomplished Develop, test, and execute a graphic application for s
ID: 3916389 • Letter: W
Question
What Will Be Accomplished
Develop, test, and execute a graphic application for simulations using Java.
Create a Java application.
Given a set of events, choose the appropriate programming actions.
Work with Java in a way that demonstrates an understanding of the principles behind the programming language.
Demonstrate an understanding of the principles of object-oriented programming including classes and inheritance.
Integrate an understanding of XML and apply this understanding to Java.
Deliverables
.java files as requested below
XML files
Basic Requirements
The final project game: The scenario is based on the Pennsylvania State University system. A character (a student, a football player, a famous Penn State icon, etc.,) will be walking around the state of Pennsylvania and will enter five campuses, one at a time. At each campus, the character will face challenges such as answering questions, solving a puzzle, or playing a game. The character will collect points in each location. After five visits, the game will end. Then a final screen will be shown, displaying the character's rankings according to his/her performance.
Detailed Requirements
The Map
The character will move on a map. It might be a sketch built with graphics (panels, buttons, etc.,) and a picture background.
The application has to have more than five campuses so the user has a choice of where to go. Find a creative way to also represent World Campus. It might be a special key or place for the character to enter World Campus. In order to enter the other campuses, the character has to be moved over the campus position on the screen.
The Campuses
As the character enters a campus, a new panel should show up. The panel will have one or more questions, or a challenge (a puzzle or a game). When the answer is given or the challenge is over, the character should be put back on the main map screen where he/she was last. You should keep score of the character's performance to use it in the final ranking.
The Character
The character has to be picked from a list of three choices. Each choice should make the character different; for instance, it might move faster, it might, more or less, be able to answer the questions, or have more or less speed or strength when he/she plays the games at each campus.
The Character's Movement
The character will be moved using the mouse and clicking on buttons to enter each campus. The mouse should have an icon representing the character.
The Theme
The user might choose from three different options for a game theme. For instance, the theme might be Penn State football and the questions and games will be themed around that. Also, the theme might be Math and the questions and puzzles will regard Math. The theme options are your choice.
Game Over
When the character has entered and interacted with five campuses, the game is over and a final screen with the character's score should be displayed.
XML
For extra points:
The text of the questions and of the final ranking can be kept in a file and read when needed. You have to use what you learned in the XML lesson to read and write the file. XML is the required format, and it should be used as explained in the lesson.
The Timer
The time (duration of gameplay) should be kept, displayed at all times (you might use a progress bar, for instance), and be part of the final ranking. You might choose to give a time limit and require players to enter five campuses before the time limit is reached. A final screen with score and timing should be shown anyway.
Class Structure
All the projects:
Have to start the basic class with the main method. It will create a JFrame, specified below
Will have their own JFrame extending from Java's JFrame. This JFrame will create a JPanel specified below
Will have their own JPanel extending from Java's JPanel
Java Code
It has to be based on the examples given in class and in the textbook. If you intend to use advanced code, clear it with the instructor first.
Suggestions
Use inheritance where appropriate. Use parameters to reuse code. For instance, the questions panel might use a one-panel class that receives different parameters (number of questions, the name of the file with the questions, theme). Use the course examples and your own labs to get started. Start simple: start with something you might be more comfortable with. It might be the main screen, the character movement, or creating one questions/answers panel. Try to follow the lesson's examples and standards.
The instructor will interact with groups and will answer direct questions. Students are expected to think, explore issues, and do research.
Groups do better work than individuals and must pull together. Every member of a group is responsible for the group product. Each member must be involved with all of the activities. Group activity will be closely monitored and necessary changes to groups will happen where appropriate.
Groups have their own unique group space right within this course environment. In groups (accessed through people), you have the ability see who is in your group, post announcements to all members at once, start discussions, add files, and initiate conference meetings with group members.
Explanation / Answer
Ans Given By :
1.Intro.java
import javax.swing.JFrame;
public class Intro extends javax.swing.JPanel {
static JFrame frame;
public Intro() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
mainMap = new javax.swing.JButton();
options = new javax.swing.JButton();
instructions = new javax.swing.JButton();
credits = new javax.swing.JButton();
jLabel1.setText("Welcome to Game");
mainMap.setText("Main Map");
mainMap.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mainMapActionPerformed(evt);
}
});
options.setText("Options");
options.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
optionsActionPerformed(evt);
}
});
instructions.setText("Instructions");
instructions.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
instructionsActionPerformed(evt);
}
});
credits.setText("Credits");
credits.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
creditsActionPerformed(evt);
}
});
2.javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(157, 157, 157)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(mainMap)
.addGap(37, 37, 37)
.addComponent(options)
.addGap(35, 35, 35)
.addComponent(instructions)
.addGap(39, 39, 39)
.addComponent(credits)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(45, 45, 45)
.addComponent(jLabel1)
.addGap(52, 52, 52)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(mainMap)
.addComponent(options)
.addComponent(instructions)
.addComponent(credits))
.addContainerGap(36, Short.MAX_VALUE))
);
}// </editor-fold>
private void mainMapActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Intro.frame.dispose();
new MainMap(Intro.frame);
}
private void creditsActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Intro.frame.dispose();
new CreditsPanel(Intro.frame);
}
private void instructionsActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Intro.frame.dispose();
new InstructionsPanel(Intro.frame);
}
private void optionsActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Intro.frame.dispose();//dispose this frame and make the intro frame visible again
new OptionsPanel(Intro.frame);
}
public static void main(String[] args) {
frame=new JFrame();//create a new frame
frame.setContentPane(new Intro());//set the content pane of frame to the panel created in this class
frame.setSize(500,200);//set the size of frame
frame.setLocationRelativeTo(null);//Position the frame on center of screen
frame.setVisible(true);//show the frame
frame.setTitle("Game Introduction");//set the title of frame
frame.setResizable(false);//make sure it can't be resized
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//exit application when user closes this frame
}
// Variables declaration - do not modify
private javax.swing.JButton credits;
private javax.swing.JButton instructions;
private javax.swing.JLabel jLabel1;
private javax.swing.JButton mainMap;
private javax.swing.JButton options;
// End of variables declaration
MainMap.java
import javax.swing.JFrame;
public class MainMap extends javax.swing.JPanel {
JFrame introScreen;
JFrame frame;
public MainMap(JFrame introScreen) {
this.introScreen = introScreen;
frame = new JFrame();
frame.setContentPane(this);
frame.setSize(500, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setTitle("Main Game");
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton1.setText("Game 1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("Game 2");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("Game 3");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton4.setText("Game 4");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jButton5.setText("Go Home");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jButton6.setText("Game Over");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
jButton7.setText("Game 5");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton5)
.addGap(35, 35, 35)
.addComponent(jButton6)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jButton2)
.addGap(18, 18, 18)
.addComponent(jButton3)
.addGap(18, 18, 18)
.addComponent(jButton4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton7)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(80, 80, 80)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2)
.addComponent(jButton3)
.addComponent(jButton4)
.addComponent(jButton7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton5)
.addComponent(jButton6))
.addContainerGap(44, Short.MAX_VALUE))
);
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
frame.setVisible(false);
new Game1(frame);
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
frame.dispose();
introScreen.setVisible(true);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
frame.setVisible(false);
new Game2(frame);
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
frame.setVisible(false);
new Game3(frame);
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
frame.setVisible(false);
new Game4(frame);
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
frame.setVisible(false);
new GameOver(frame);
}
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
frame.setVisible(false);
new Game5(frame);
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
// End of variables declaration
3.
Game1.java
import javax.swing.JFrame;
public class Game1 extends javax.swing.JPanel {
JFrame mainFrame;
JFrame frame;
public Game1(JFrame mainFrame) {
this.mainFrame=mainFrame;
frame=new JFrame();
frame.setContentPane(this);
frame.setSize(300,200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setTitle("Game 1");
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
initComponents();
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jButton1.setText("Main Map");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel1.setText("Game 1 will be here");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(58, 58, 58)
.addComponent(jButton1))
.addGroup(layout.createSequentialGroup()
.addGap(47, 47, 47)
.addComponent(jLabel1)))
.addContainerGap(260, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(44, 44, 44)
.addComponent(jLabel1)
.addGap(33, 33, 33)
.addComponent(jButton1)
.addContainerGap(186, Short.MAX_VALUE))
);
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
frame.dispose();
mainFrame.setVisible(true);
4.
Game2.java
import javax.swing.JFrame;
public class Game2 extends javax.swing.JPanel {
JFrame mainFrame;
JFrame frame;
public Game2(JFrame mainFrame) {
this.mainFrame=mainFrame;
frame=new JFrame();
frame.setContentPane(this);
frame.setSize(300,200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setTitle("Game 2");
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jButton1.setText("Main Map");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel1.setText("Game 2 will be here");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(58, 58, 58)
.addComponent(jButton1))
.addGroup(layout.createSequentialGroup()
.addGap(47, 47, 47)
.addComponent(jLabel1)))
.addContainerGap(260, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(44, 44, 44)
.addComponent(jLabel1)
.addGap(33, 33, 33)
.addComponent(jButton1)
.addContainerGap(186, Short.MAX_VALUE))
);
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
frame.dispose();
mainFrame.setVisible(true);
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
// End of variables declaration
5.
Game3.java
import javax.swing.JFrame;
public class Game3 extends javax.swing.JPanel {
JFrame mainFrame;
JFrame frame;
public Game3(JFrame mainFrame) {
this.mainFrame=mainFrame;
frame=new JFrame();
frame.setContentPane(this);
frame.setSize(300,200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setTitle("Game 3");
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
initComponents();
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jButton1.setText("Main Map");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel1.setText("Game 3 will be here");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(58, 58, 58)
.addComponent(jButton1))
.addGroup(layout.createSequentialGroup()
.addGap(47, 47, 47)
.addComponent(jLabel1)))
.addContainerGap(260, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(44, 44, 44)
.addComponent(jLabel1)
.addGap(33, 33, 33)
.addComponent(jButton1)
.addContainerGap(186, Short.MAX_VALUE))
);
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
frame.dispose();
mainFrame.setVisible(true);
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
// End of variables declaration
}
6.
Game3.java
import javax.swing.JFrame;
public class Game3 extends javax.swing.JPanel {
JFrame mainFrame;
JFrame frame;
public Game3(JFrame mainFrame) {
this.mainFrame=mainFrame;
frame=new JFrame();
frame.setContentPane(this);
frame.setSize(300,200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setTitle("Game 3");
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
initComponents();
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jButton1.setText("Main Map");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel1.setText("Game 3 will be here");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(58, 58, 58)
.addComponent(jButton1))
.addGroup(layout.createSequentialGroup()
.addGap(47, 47, 47)
.addComponent(jLabel1)))
.addContainerGap(260, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(44, 44, 44)
.addComponent(jLabel1)
.addGap(33, 33, 33)
.addComponent(jButton1)
.addContainerGap(186, Short.MAX_VALUE))
);
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
frame.dispose();
mainFrame.setVisible(true);
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
7.
Game3.java
import javax.swing.JFrame;
public class Game3 extends javax.swing.JPanel {
JFrame mainFrame;
JFrame frame;
public Game3(JFrame mainFrame) {
this.mainFrame=mainFrame;
frame=new JFrame();
frame.setContentPane(this);
frame.setSize(300,200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setTitle("Game 3");
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
initComponents();
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jButton1.setText("Main Map");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel1.setText("Game 3 will be here");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(58, 58, 58)
.addComponent(jButton1))
.addGroup(layout.createSequentialGroup()
.addGap(47, 47, 47)
.addComponent(jLabel1)))
.addContainerGap(260, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(44, 44, 44)
.addComponent(jLabel1)
.addGap(33, 33, 33)
.addComponent(jButton1)
.addContainerGap(186, Short.MAX_VALUE))
);
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
frame.dispose();
mainFrame.setVisible(true);
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
8.
InstructionsPanel.java
import javax.swing.JFrame;
public class InstructionsPanel extends javax.swing.JPanel {
JFrame introScreen;
JFrame frame;
public InstructionsPanel(JFrame introScreen) {
this.introScreen=introScreen;
frame=new JFrame();
frame.setContentPane(this);
frame.setSize(300,200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setTitle("Game Instructions");
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
initComponents();
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jButton1.setText("Go Home");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel1.setText("Instructions");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(97, 97, 97)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton1)
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLabel1)))
.addContainerGap(100, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(55, 55, 55)
.addComponent(jLabel1)
.addGap(42, 42, 42)
.addComponent(jButton1)
.addContainerGap(69, Short.MAX_VALUE))
);
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
frame.dispose();
introScreen.setVisible(true);
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
9.
CreditsPanel.java
import javax.swing.JFrame;
public class CreditsPanel extends javax.swing.JPanel {
JFrame introScreen;
JFrame frame;
public CreditsPanel(JFrame introScreen) {
this.introScreen=introScreen;
frame=new JFrame();
frame.setContentPane(this);
frame.setSize(300,200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setTitle("Game Credits");
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel1.setText(" Game Credits");
jButton1.setText("Go Home");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(109, 109, 109)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addContainerGap(91, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton1)
.addContainerGap(44, Short.MAX_VALUE))
);
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
frame.dispose();
introScreen.setVisible(true);
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.