EDIT: MyDrawPanel is this:
class MyDrawPanel extends JPanel {
public void paintComponent(Graphics g) {
g.setColor(Color.RED);
g.fillOval(d, e, 40, 40);
}
}
I'm having a frustrating problem with this small lump of code. I'm trying to create a new MyDrawPanel. Code:
class Simulation{
MyDrawPanel drawPanel = new MyDrawPanel();
public static void startSimulation() {
frame.getContentPane().add(drawPanel); //drawPanel must be static
}
}
Here's the issue: Eclipse tells me that drawPanel must be static. But, whenever I change it to static, Eclipse gives an error basically telling me to get rid of the static.
I've done research, and this is what I found: https://stackoverflow.com/a/9560633/4778083 This person tells me that I should make the class static, but whenever I do, Eclipse tells me, "Illegal modifier for the class Simulation; only public, abstract & final are permitted."
So basically, I'm stuck. What is wrong with my code?