Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import javax.swing.JPanel.*;
- import javax.swing.JFrame.*;
- import java.awt.event.*;
- /**
- * Write a description of class chasingBombs here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class chasingBombs extends JFrame
- {
- private JFrame frame = new JFrame("Chasing Bombs");
- private int ROWS = 2;
- private int COLS = 5;
- private int GAP = 4;
- private int NUM = ROWS * COLS;
- private int x;
- private int score = 0;
- private JPanel panelLeft = new JPanel(new GridLayout(ROWS, COLS, GAP, GAP));
- private JPanel panelMiddle = new JPanel();
- private JPanel panelRight = new JPanel();
- private JLabel [] gamePanel = new JLabel[NUM];
- private JLabel scoreBoard = new JLabel(String.valueOf(score));
- private JButton startButton = new JButton("Start a Game");
- private JButton exitButton = new JButton("Exit");
- private JButton easy = new JButton("Easy");
- private JButton intermediate = new JButton ("Intermediate");
- private JButton difficult = new JButton ("Difficult");
- /**
- * Constructor for objects of class chasingBombs
- */
- public chasingBombs()
- {
- makeFrame();
- }
- /**
- * An example of a method - replace this comment with your own
- *
- * @param y a sample parameter for a method
- * @return the sum of x and y
- */
- public void makeFrame()
- {
- frame.setSize(1000,500);
- frame.setVisible(true);
- frame.setLayout(new GridLayout());
- leftSetup();
- middleSetup();
- rightSetup();
- }
- public void leftSetup()
- {
- frame.add(panelLeft);
- panelLeft.setBackground(Color.BLUE);
- for(x = 0; x < NUM; x++){
- gamePanel[x] = new JLabel();
- gamePanel[x].setOpaque(true);
- gamePanel[x].setBackground(Color.PINK);
- gamePanel[x].addMouseListener(new MouseAdapter()
- {
- @Override
- public void mouseReleased(MouseEvent e)
- {
- System.out.println("Panel Clicked");
- }
- });
- panelLeft.add(gamePanel[x]);
- }
- }
- public void middleSetup()
- {
- frame.add(panelMiddle);
- panelMiddle.setBackground(Color.RED);
- panelMiddle.add(startButton);
- panelMiddle.add(exitButton);
- panelMiddle.add(scoreBoard);
- }
- public void rightSetup()
- {
- frame.add(panelRight);
- panelRight.setBackground(Color.GREEN);
- panelRight.add(easy);
- panelRight.add(intermediate);
- panelRight.add(difficult);
- }
- public void onClick()
- {
- this.setBackground(Color.GRAY);
- }
- public void gameplay()
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement