4 Replies - 2495 Views - Last Post: 19 March 2014 - 07:33 AM Rate Topic: -----

#1 Coder4Life   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 18-March 14

GUI Restart Button Help

Posted 18 March 2014 - 07:17 PM

Hi guy would really appreciate it if somebody could tell me how to make this restart button work. This is what I have so far. I have put the restart button code in red and bold...


package Game;

/**
*
* @author Sasha
*/
public class Buttons extends javax.swing.JPanel {

private GameWorld world;
private int restart;


public Buttons() {
restart = 1;
world = new GameWorld();


}

public Buttons(GameWorld world) {
this.world = world;
initComponents();
}

@SuppressWarnings("unchecked")


private void QuitButtonActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}

private void PauseButtonActionPerformed(java.awt.event.ActionEvent evt) {
world.setPaused(true);
}

private void PlayButtonActionPerformed(java.awt.event.ActionEvent evt) {
world.setPaused(false);
}

private void RestartButtonActionPerformed(java.awt.event.ActionEvent evt) {
restart++;
world.start();
world = new GameWorld();

}


private javax.swing.JButton PauseButton;
private javax.swing.JButton PlayButton;
private javax.swing.JButton QuitButton;
private javax.swing.JButton RestartButton;




}


This post has been edited by no2pencil: 18 March 2014 - 07:31 PM
Reason for edit:: added code tags


Is This A Good Question/Topic? 0
  • +

Replies To: GUI Restart Button Help

#2 ben255   User is offline

  • D.I.C Addict

Reputation: 46
  • View blog
  • Posts: 573
  • Joined: 09-September 13

Re: GUI Restart Button Help

Posted 19 March 2014 - 02:05 AM

try makeing a restart method in your gameworld class
Was This Post Helpful? 0
  • +
  • -

#3 x68zeppelin80x   User is offline

  • D.I.C Addict

Reputation: 130
  • View blog
  • Posts: 576
  • Joined: 07-March 09

Re: GUI Restart Button Help

Posted 19 March 2014 - 02:42 AM

You should have a setupGame() method that gets called in your constructor, as well as when you choose to restart the game. Write the business logic before the GUI.

Do not try to run before you can walk.
Was This Post Helpful? 0
  • +
  • -

#4 CasiOo   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1578
  • View blog
  • Posts: 3,551
  • Joined: 05-April 11

Re: GUI Restart Button Help

Posted 19 March 2014 - 04:49 AM

View Postx68zeppelin80x, on 19 March 2014 - 09:42 AM, said:

You should have a setupGame() method that gets called in your constructor, as well as when you choose to restart the game. Write the business logic before the GUI.

Do not try to run before you can walk.

You should be able to develope the presentation layer without the need of a fully functional business layer
It usually helps to have wireframes/mockups/use cases, and loosely couple the presentation and business layers together using interfaces
That way you can work on the two separately
Was This Post Helpful? 0
  • +
  • -

#5 Coder4Life   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 18-March 14

Re: GUI Restart Button Help

Posted 19 March 2014 - 07:33 AM

View Postx68zeppelin80x, on 19 March 2014 - 02:42 AM, said:

You should have a setupGame() method that gets called in your constructor, as well as when you choose to restart the game. Write the business logic before the GUI.

Do not try to run before you can walk.


Could you give me an example of what I could write, I am really stuck. Thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1