Help with creating a game in blueJ

Discussion in 'Software' started by lauraa, Apr 18, 2010.

  1. lauraa

    lauraa

    Joined:
    Apr 18, 2010
    Messages:
    2
    Hi i have created a basic game in blueJ and would like to know if anyone knew how i would go about pausing and resuming my game. I have created a controlPanel class with the Jbutton for pause but am unsure about the code needed to pause the game. the code for my control panel class is below.
    Thanks for your help in advance



    import java.awt.event.ActionEvent;

    import java.awt.event.*;
    import javax.swing.*;

    public class ControlPanel extends JPanel implements ActionListener
    {

    private Game game;
    private JButton quitButton;
    private JButton pauseButton;



    public ControlPanel(Game g)
    {
    super();
    this.game = g;

    quitButton = new JButton("Quit");
    add(quitButton);
    quitButton.addActionListener(this);
    quitButton.setFocusable(false);
    pauseButton = new JButton("Pause");
    add(pauseButton);
    pauseButton.addActionListener(this);
    pauseButton.setFocusable(false);
    }

    public void actionPerformed(ActionEvent g)
    {
    Object source = g.getSource();
    if (source == quitButton) {
    System.exit(0);
    } else if (source == pauseButton) {
    //Code to pause the game
    lauraa, Apr 18, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BobW

    Help creating desktop shortcu

    BobW, Apr 10, 2005, in forum: Firefox
    Replies:
    10
    Views:
    2,623
  2. B. Gray
    Replies:
    3
    Views:
    690
    Walter Roberson
    Aug 16, 2005
  3. rspike@comcast.net

    Help - Creating a Wireless Bridge with 2 Belkin Routers

    rspike@comcast.net, Mar 12, 2006, in forum: Wireless Networking
    Replies:
    3
    Views:
    27,081
    rspike@comcast.net
    Mar 19, 2006
  4. Travis

    Please Help on Creating Dual Boot System

    Travis, Oct 9, 2003, in forum: Computer Support
    Replies:
    11
    Views:
    619
    B. Al. Zeebub
    Oct 10, 2003
  5. lauraa
    Replies:
    0
    Views:
    2,010
    lauraa
    Apr 18, 2010
Loading...

Share This Page