Search:

Type: Posts; User: Norm

Search: Search took 0.12 seconds.

  1. Replies
    42
    Views
    3,705

    Re: A beginner needs help in oop

    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.
    ...
  2. Replies
    42
    Views
    3,705

    Re: A beginner needs help in oop

    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...
  3. Replies
    42
    Views
    3,705

    Re: A beginner needs help in oop

    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.
  4. Replies
    42
    Views
    3,705

    Re: A beginner needs help in oop

    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...
  5. Replies
    42
    Views
    3,705

    Re: A beginner needs help in oop

    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...
  6. Replies
    42
    Views
    3,705

    Re: A beginner needs help in oop

    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...
  7. Replies
    42
    Views
    3,705

    Re: A beginner needs help in oop

    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...
  8. Replies
    42
    Views
    3,705

    Re: A beginner needs help in oop

    Post the full text of the error messages and the code.
  9. Replies
    42
    Views
    3,705

    Re: A beginner needs help in oop

    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...
  10. Replies
    42
    Views
    3,705

    Re: A beginner needs help in oop

    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.
  11. Replies
    42
    Views
    3,705

    Re: A beginner needs help in oop

    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...
  12. Replies
    42
    Views
    3,705

    Re: A beginner needs help in oop

    Please copy the full text of the error message and paste it here. It has important info about the error.
Results 1 to 12 of 12