|
|
Re: cannot be referenced from a static context
|
Posted: Apr 12, 2007 1:48 AM
|
|
Hi,
Do not call jump method using Game.jump. Because its not static. So there are two ways now: 1. Declare jump method as static private static void jump() {...}
2. Or else create an object of Game and then call jump private void jButton1_actionPerformed(ActionEvent e) { System.out.println( "\njButton1_actionPerformed(ActionEvent e) called."); // code Game game = new Game(); game.jump(); }
Regards, Rajeev
> im trying to link my user interface to the Game class to > jump, > i get the error - non static method jump() cannot be > referenced from a static context > > private void jButton1_actionPerformed(ActionEvent e) > { > System.out.println("\njButton1_actionPerformed(ActionEve > nt e) called."); > // code > Game.jump(); > } > > any ideas? thanks
|
|