Having problems calling a non-static method for a static context

I

iMohed

I guess the title says it all. I just dont understand why i cant cal
my Main.play() from my Model class. Both in the same package.

Model class short :

public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
clickButton(source);
}

public void clickButton(Object o) {
int i = 0;
for (MButton s : this.but) {
if (s == o) {
Main.play(i);
}
}
}

Main class short :

public void play(int k) throws IOException {
while (game.finish == false) {
game.doTurn(k);
int j = 0;
for (Model.Square squares : game.sq) {
communication[j] = squares.value;
j++;
}
gameGfx.setColors(communication);
}
}

Any ideas guys and gals ??
Mohamed Haidar.
 
K

Knute Johnson

I guess the title says it all. I just dont understand why i cant cal
my Main.play() from my Model class. Both in the same package.

Model class short :

public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
clickButton(source);
}

public void clickButton(Object o) {
int i = 0;
for (MButton s : this.but) {
if (s == o) {
Main.play(i);
}
}
}

Main class short :

public void play(int k) throws IOException {
while (game.finish == false) {
game.doTurn(k);
int j = 0;
for (Model.Square squares : game.sq) {
communication[j] = squares.value;
j++;
}
gameGfx.setColors(communication);
}
}

Any ideas guys and gals ??
Mohamed Haidar.

Either new Main().play() or make play static.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,979
Messages
2,570,185
Members
46,722
Latest member
NelsonHeil

Latest Threads

Top