Possible Duplicate:
What is the reason behind “non-static method cannot be referenced from a static context”?
I have the following method:
public void fillMachine(Game game)
{
// Colours of balls are evenly spread between these colours,
// in ascending order.
Color [] colourGroupColours
= new Color [] {Color.red, Color.orange, Color.yellow,
Color.green, Color.blue, Color.pink,
Color.magenta};
// This happiness change will show up when the GUI is added.
Color ballColour;
int noOfBalls = game.getMachineSize();
for (int count = 1; count <= noOfBalls; count++)
{
// The colour group is a number from 0
// to the number of colour groups - 1.
// For the nth ball, we take the fraction
// (n - 1) divided by the number of balls
// and multiply that by the number of groups.
int colourGroup = (int) ((count - 1.0) / (double) noOfBalls
* (double) colourGroupColours.length);
ballColour = colourGroupColours[colourGroup];
game.machineAddBall(makeNewBall(count, ballColour));
} // for
} // fillMachine
In the main class I have fillMachine(game1);
I am getting the error: non-static method fillMachine(Game) cannot be referenced from a static context
fillMachine(game1);
I'm not sure how to fix this though.