Skip to content
Snippets Groups Projects
Commit 1ef9d05c authored by Samita Adhikari's avatar Samita Adhikari
Browse files

Closes #13 Add main Menu and Guest playable

parent 7cba58cb
No related branches found
No related tags found
No related merge requests found
......@@ -2,16 +2,19 @@
package brickbreaker;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class App {
public static void main(String[] args) {
JFrame obj = new JFrame();
GamePanel gamePanel = new GamePanel();
obj.setBounds(10, 10, 700, 600);
obj.setTitle("Brick Breaker");
obj.setResizable(false);
obj.setVisible(true);
obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
obj.add(gamePanel);
JFrame frame = new JFrame();
JPanel panel = new JPanel();
new Menu(frame);
frame.setBounds(10, 10, 700, 600);
frame.setTitle("Brick Breaker");
frame.setResizable(false);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(panel);
}
}
......@@ -9,12 +9,11 @@ import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class GamePanel extends JPanel implements KeyListener, ActionListener {
public class GamePanel extends JPanel implements ActionListener {
private boolean play = true;
private int score = 0;
......@@ -32,18 +31,19 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
private GameMapBuilder gameMap;
public GamePanel() {
public GamePanel(JFrame frame) {
Color color = Color.decode("#8B4513");
this.balls.add(new Ball(350, 450, 2, -2, 20, color));
this.totalBricks = rows * columns;
BrickFactory brickfactory = new DefaultBrickFactory();
gameMap = new GameMapBuilder(rows, columns, brickfactory);
addKeyListener(this);
setFocusable(true);
setFocusTraversalKeysEnabled(false);
timer = new Timer(delay, this);
timer.start();
frame.add(this);
addKeyBindings();
}
private List<GameObserver> observers = new ArrayList<>();
......@@ -56,6 +56,54 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
observers.remove(observer);
}
private void addKeyBindings() {
InputMap inputMap = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
ActionMap actionMap = getActionMap();
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "moveLeft");
actionMap.put("moveLeft", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if (paddle < 10) {
paddle = 10;
} else {
moveLeft();
}
}
});
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "moveRight");
actionMap.put("moveRight", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if (paddle >= 600) {
paddle = 600;
} else {
moveRight();
}
}
});
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter");
actionMap.put("Enter", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if (!play) {
play = true;
Color color = Color.decode("#8B4513");
balls.clear();
balls.add(new Ball(350, 450, 2, -2, 20, color));
score = 0;
totalBricks = rows * columns;
BrickFactory brickfactory = new DefaultBrickFactory();
gameMap = new GameMapBuilder(rows, columns, brickfactory);
repaint();
}
}
});
}
protected void paintComponent(Graphics graphics) {
super.paintComponent(graphics);
if (balls.isEmpty()) {
......@@ -143,7 +191,6 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
if(brick.hasPowerUp) {
int noOfBallsToSpawn = (int) (Math.random() * 5);
System.out.println(noOfBallsToSpawn);
for (int k=0; k<noOfBallsToSpawn; k++) {
boolean positiveXDirection = Math.random() > 0.5;
boolean positiveYDirection = Math.random() > 0.5;
......@@ -174,43 +221,6 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
repaint();
}
@Override
public void keyTyped(KeyEvent arg0) {
}
@Override
public void keyPressed(KeyEvent arg0) {
if (arg0.getKeyCode() == KeyEvent.VK_RIGHT) {
if (paddle >= 600) {
paddle = 600;
} else {
moveRight();
}
}
if (arg0.getKeyCode() == KeyEvent.VK_LEFT) {
if (paddle < 10) {
paddle = 10;
} else {
moveLeft();
}
}
if (arg0.getKeyCode() == KeyEvent.VK_ENTER) {
if (!play) {
play = true;
Color color = Color.decode("#8B4513");
this.balls.clear();
this.balls.add(new Ball(350, 450, 2, -2, 20, color));
score = 0;
totalBricks = rows * columns;
BrickFactory brickfactory = new DefaultBrickFactory();
gameMap = new GameMapBuilder(rows, columns, brickfactory);
repaint();
}
}
}
public void moveRight() {
play = true;
paddle += 50;
......@@ -221,7 +231,5 @@ public class GamePanel extends JPanel implements KeyListener, ActionListener {
paddle -= 50;
}
@Override
public void keyReleased(KeyEvent arg0) {
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="310" max="-2" attributes="0"/>
<Component id="loginButton" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="301" max="-2" attributes="0"/>
<Component id="registerButton" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="282" max="-2" attributes="0"/>
<Component id="guest" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="290" max="-2" attributes="0"/>
<Component id="highScore" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="122" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="143" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="117" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="loginButton" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="registerButton" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="guest" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="highScore" max="-2" attributes="0"/>
<EmptySpace pref="228" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="loginButton">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="e2" green="ac" red="24" type="rgb"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="MV Boli" size="14" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="e2" green="ac" red="24" type="rgb"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="login"/>
<Property name="actionCommand" type="java.lang.String" value="Login"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Hand Cursor"/>
</Property>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="label" type="java.lang.String" value="Login"/>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="registerButton">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="e2" green="ac" red="24" type="rgb"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="MV Boli" size="14" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="Register"/>
<Property name="actionCommand" type="java.lang.String" value="Login"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Hand Cursor"/>
</Property>
<Property name="horizontalTextPosition" type="int" value="0"/>
</Properties>
<Events>
<EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="registerButtonMouseEntered"/>
<EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="registerButtonMouseExited"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="registerButtonActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextPane" name="welconText">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="MV Boli" size="36" style="1"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="c0" red="ff" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="Welcome to Brick Breaker"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="guest">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="e2" green="ac" red="24" type="rgb"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="MV Boli" size="14" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="actionCommand" type="java.lang.String" value="play"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Hand Cursor"/>
</Property>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="label" type="java.lang.String" value="Play as Guest"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="guestActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="highScore">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="e2" green="ac" red="24" type="rgb"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="MV Boli" size="14" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="High Scores"/>
<Property name="actionCommand" type="java.lang.String" value="play"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Hand Cursor"/>
</Property>
<Property name="horizontalTextPosition" type="int" value="0"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="highScoreActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
package brickbreaker;
/**
*
* @author Suman
*/
public class MainMenu extends javax.swing.JFrame {
/**
* Creates new form MainMenu
*/
public MainMenu() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
loginButton = new javax.swing.JButton();
registerButton = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
welconText = new javax.swing.JTextPane();
guest = new javax.swing.JButton();
highScore = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(255, 255, 255));
loginButton.setBackground(new java.awt.Color(36, 172, 226));
loginButton.setFont(new java.awt.Font("MV Boli", 0, 14)); // NOI18N
loginButton.setForeground(new java.awt.Color(36, 172, 226));
loginButton.setToolTipText("login");
loginButton.setActionCommand("Login");
loginButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
loginButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
loginButton.setLabel("Login");
loginButton.setOpaque(false);
registerButton.setBackground(new java.awt.Color(36, 172, 226));
registerButton.setFont(new java.awt.Font("MV Boli", 0, 14)); // NOI18N
registerButton.setForeground(new java.awt.Color(255, 255, 255));
registerButton.setText("Register");
registerButton.setActionCommand("Login");
registerButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
registerButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
registerButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
registerButtonMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
registerButtonMouseExited(evt);
}
});
registerButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
registerButtonActionPerformed(evt);
}
});
welconText.setEditable(false);
welconText.setBorder(null);
welconText.setFont(new java.awt.Font("MV Boli", 1, 36)); // NOI18N
welconText.setForeground(new java.awt.Color(255, 192, 0));
welconText.setText("Welcome to Brick Breaker");
welconText.setToolTipText("");
welconText.setFocusable(false);
welconText.setOpaque(false);
jScrollPane1.setViewportView(welconText);
guest.setBackground(new java.awt.Color(36, 172, 226));
guest.setFont(new java.awt.Font("MV Boli", 0, 14)); // NOI18N
guest.setForeground(new java.awt.Color(255, 255, 255));
guest.setActionCommand("play");
guest.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
guest.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
guest.setLabel("Play as Guest");
guest.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
guestActionPerformed(evt);
}
});
highScore.setBackground(new java.awt.Color(36, 172, 226));
highScore.setFont(new java.awt.Font("MV Boli", 0, 14)); // NOI18N
highScore.setForeground(new java.awt.Color(255, 255, 255));
highScore.setText("High Scores");
highScore.setActionCommand("play");
highScore.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
highScore.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
highScore.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
highScoreActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().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(310, 310, 310)
.addComponent(loginButton))
.addGroup(layout.createSequentialGroup()
.addGap(301, 301, 301)
.addComponent(registerButton))
.addGroup(layout.createSequentialGroup()
.addGap(282, 282, 282)
.addComponent(guest))
.addGroup(layout.createSequentialGroup()
.addGap(290, 290, 290)
.addComponent(highScore))
.addGroup(layout.createSequentialGroup()
.addGap(122, 122, 122)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(143, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(117, 117, 117)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(loginButton)
.addGap(18, 18, 18)
.addComponent(registerButton)
.addGap(18, 18, 18)
.addComponent(guest)
.addGap(18, 18, 18)
.addComponent(highScore)
.addContainerGap(228, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void registerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_registerButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_registerButtonActionPerformed
private void guestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_guestActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_guestActionPerformed
private void highScoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_highScoreActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_highScoreActionPerformed
private void registerButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_registerButtonMouseEntered
// TODO add your handling code here:
}//GEN-LAST:event_registerButtonMouseEntered
private void registerButtonMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_registerButtonMouseExited
// TODO add your handling code here:
}//GEN-LAST:event_registerButtonMouseExited
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton guest;
private javax.swing.JButton highScore;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JButton loginButton;
private javax.swing.JButton registerButton;
private javax.swing.JTextPane welconText;
// End of variables declaration//GEN-END:variables
}
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package brickbreaker;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
/**
*
* @author Suman
*/
public class Menu extends JPanel {
private JButton guest;
private JButton highScore;
private JScrollPane jScrollPane1;
private JButton loginButton;
private JButton registerButton;
private JTextPane welconText;
private JFrame frame;
public Menu(JFrame frame) {
this.frame = frame;
initComponents();
}
private void initComponents() {
loginButton = new javax.swing.JButton();
registerButton = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
welconText = new javax.swing.JTextPane();
guest = new javax.swing.JButton();
highScore = new javax.swing.JButton();
loginButton.setBackground(new java.awt.Color(36, 172, 226));
loginButton.setFont(new java.awt.Font("MV Boli", 0, 14)); // NOI18N
loginButton.setForeground(new java.awt.Color(36, 172, 226));
loginButton.setToolTipText("login");
loginButton.setActionCommand("Login");
loginButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
loginButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
loginButton.setLabel("Login");
loginButton.setOpaque(false);
registerButton.setBackground(new java.awt.Color(36, 172, 226));
registerButton.setFont(new java.awt.Font("MV Boli", 0, 14)); // NOI18N
registerButton.setForeground(new java.awt.Color(255, 255, 255));
registerButton.setText("Register");
registerButton.setActionCommand("Login");
registerButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
registerButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
registerButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
registerButtonMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
registerButtonMouseExited(evt);
}
});
registerButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
registerButtonActionPerformed(evt);
}
});
welconText.setEditable(false);
welconText.setBorder(null);
welconText.setFont(new java.awt.Font("MV Boli", 1, 36)); // NOI18N
welconText.setForeground(new java.awt.Color(255, 192, 0));
welconText.setText("Welcome to Brick Breaker");
welconText.setToolTipText("");
welconText.setFocusable(false);
welconText.setOpaque(false);
jScrollPane1.setViewportView(welconText);
jScrollPane1.setBorder(BorderFactory.createEmptyBorder());
guest.setBackground(new java.awt.Color(36, 172, 226));
guest.setFont(new java.awt.Font("MV Boli", 0, 14)); // NOI18N
guest.setForeground(new java.awt.Color(255, 255, 255));
guest.setActionCommand("play");
guest.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
guest.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
guest.setLabel("Play as Guest");
guest.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
guestActionPerformed(evt);
}
});
highScore.setBackground(new java.awt.Color(36, 172, 226));
highScore.setFont(new java.awt.Font("MV Boli", 0, 14)); // NOI18N
highScore.setForeground(new java.awt.Color(255, 255, 255));
highScore.setText("High Scores");
highScore.setActionCommand("play");
highScore.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
highScore.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
highScore.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
highScoreActionPerformed(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()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(310, 310, 310)
.addComponent(loginButton))
.addGroup(layout.createSequentialGroup()
.addGap(301, 301, 301)
.addComponent(registerButton))
.addGroup(layout.createSequentialGroup()
.addGap(282, 282, 282)
.addComponent(guest))
.addGroup(layout.createSequentialGroup()
.addGap(290, 290, 290)
.addComponent(highScore))
.addGroup(layout.createSequentialGroup()
.addGap(122, 122, 122)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(143, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(117, 117, 117)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(43, 43, 43)
.addComponent(loginButton)
.addGap(18, 18, 18)
.addComponent(registerButton)
.addGap(18, 18, 18)
.addComponent(guest)
.addGap(18, 18, 18)
.addComponent(highScore)
.addContainerGap(228, Short.MAX_VALUE))
);
frame.add(this);
}
private void registerButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void guestActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
GamePanel game = new GamePanel(frame);
}
private void highScoreActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void registerButtonMouseEntered(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
private void registerButtonMouseExited(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment