I’m being told by Eclipse to change the modifier of my string variable to static. I don’t understand why. I think I’m declaring everything right but I’m not sure.
Here’s my code. The problem is happening on both lines 12 and 13.
import java.awt.*;
import javax.swing.*;
public class MainClass {
Rectangle dot1 = new Rectangle(1,1), dot2 = new Rectangle(1,1);
JFrame frame = new JFrame("Pythagorean Theorem");
public static void main (String[] args){
frame.setVisible(true);
frame.setSize(500, 500);
}
}
You are defining
frameas an instance variable, but using it as a static variable. There are two solutions to this:1) You can change the modifier of frame to static
2) Create an instance of your class, like this: