0

I have a game that uses EventQueue.invokeLater() . I'm adding code that I want to push a new EventQueue when the game is over effectivly restarting the game but I'm getting an error in Eclipse which reads "The method push(EventQueue) in the type EventQueue is not applicable for the arguments (void)". I'm new to using the EventQueue class so it's possible there is something simple I'm not understanding or that I'm trying to use EventQueue incorrectly. Here's the bit of code where I use EventQueue.invokeLater() to run the program the first time around.

public class App extends JFrame{
    public static int level;
    public App(){
        add(new GameBoard());   
        setResizable(false);
        pack();
        setTitle("Planetary Resources Game");
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     
    }   
    public static void main(String drew[]){ 
        MyQue r = new MyQue();
        EventQueue.invokeLater(r);      
    }
}

Here is the bit of code that I want to restart the game by using the Event.Queue.push() method.

if(GameLogic.game_is_over == true){
                MyQue r = new MyQue();
                EventQueue.push(EventQueue.invokeLater(r));
                MineCalculation.rocketfuel_amount= 100;
                GameLogic.game_is_over = false; 
            }

Thank you all for your help

Algebra is Awesome
  • 273
  • 1
  • 2
  • 9
  • 1
    This approach won't work; instead, `reset()` the game's model, as shown [here](http://stackoverflow.com/a/3072979/230513). – trashgod Mar 05 '15 at 18:47

2 Answers2

1

It's because push takes an argument of type EventQueue but you've called it with the result of EventQueue.invokeLater(), which is a void method.

Ryan J
  • 8,275
  • 3
  • 25
  • 28
1

EventQueue.invokeLater(r) is a void and you can not use it as a patameter for the push method.

Jens
  • 67,715
  • 15
  • 98
  • 113