Don't make the draw() method static. Each Square object needs its own draw() method that will use the values of its variables. None of the Square class's variables or methods should be static.
...
Type: Posts; User: Norm
Don't make the draw() method static. Each Square object needs its own draw() method that will use the values of its variables. None of the Square class's variables or methods should be static.
...
Look at the code in the paintComponent() method where those methods were called.
The methods are in the Graphics class. The paintComponent() method needs to pass the Graphics object it receives to...
You can NOT use an int to call a method: i.draw();
You need to get the Square objects from the list and use the objects to call their draw() method.
By list I meant something like an ArrayList that would hold instances of the Square class that you want to draw in the paintComponent() method.
Use it something like this:
begin loop through...
Put the Square objects in a list and have the paint method go though the list (in a loop) and call each Square object's draw method. You should move the drawing code from the paintComponent() method...
That is the syntax for calling the Xposition() method and passing it the arg: 55
The class needs to define the method: Xposition(int x)
Normally methods that set the values of class variables...
Please use code tags, NOT quote tags for the code.
super.paintComponent(g);
The class Square does NOT have a super class (except Object). It would have a super class if it extended another...
Post the full text of the error messages and the code.
That definition is ONLY known within the createAndShowGUI() method.
It is NOT known anywhere else in the ObjectClassTrain class.
The code in the paintComponent() method in the myPanel class has no...
Yes, that has a good error message.
Where is the variable: squareRed defined? The compiler can NOT find a definition for it where it is used.
Can you execute the javac compiler and get its error messages. What you posted is missing important details about the error.
The message should show the source with a ^ under the location of the...
Please copy the full text of the error message and paste it here. It has important info about the error.