Search:

Type: Posts; User: Norm

Search: Search took 0.15 seconds.

  1. Replies
    11
    Views
    2,325

    Re: how to use graphics g

    To be able to "erase" a shape, you will need to create a list of shapes for the paint method to draw.
    The erase step will remove the shape from the list.
  2. Replies
    11
    Views
    2,325

    Re: how to use graphics g

    Canvas is from the old awt classes. JPanel is part of Swing and has a lot more features that can be useful.
  3. Replies
    11
    Views
    2,325

    Re: how to use graphics g

    An inner class would be useful because it would allow the class to see the enclosing class's variables.
    paint is not a good name for your class. paint is a method name for some classes and class...
  4. Replies
    11
    Views
    2,325

    Re: how to use graphics g

    Create a class that extends JPanel and in that class override the paintComponent() method.
    Add an instance of that class to your GUI where you what to see it.
  5. Replies
    11
    Views
    2,325

    Re: how to use graphics g

    Your code is confused on who does the painting. For example JFrame does not have a paintComponent() method to override.
    You should NOT override JFrame's paint method, but instead create a JPanel,...
  6. Replies
    11
    Views
    2,325

    Re: how to use graphics g

    You're not supposed to call the paint or paintComponent methods. You call the repaint() method and the JVM calls the paint method shortly after that and passes it a reference to a Graphics object....
Results 1 to 6 of 6