Originally Posted by
javapenguin
But how do people have different methods to draw something?
They override the paintComponent method of the component they want to draw on.
Also, paint seems to be being called repeatedly.
Swing calls the paint methods whenever it determines repainting may be necessary.
Also, another funny thing, I don't quite get how an abstract method from Graphics could actually draw something.
Via polymorphism. A Graphics subclass is provided that implements that method.
Also, it was someone else you told that getGraphics() was a bad idea, and I thought it was only for some certain situation.
I only used getGraphics() because I can't instantiate a Graphics object
You should not be trying to instantiate a Graphics object. Swing calls the paint methods and passes them a Graphics object that you can use when you override those methods.
I mean, is paint() the only method to draw, besides paintComponent()?
You will get nowhere without understanding how Swing GUI painting works. Read the link provided, and read this tutorial:
Custom Painting, especially
A Closer Look.
However, I needed to call paint() method in the previous bit of code inside an ActionListener and don't know how to do it without getGraphics(), which won't draw it anyway.
You clearly have no idea what you need to do.
You need to understand what it says. Also, try following the examples in the tutorial that show you how painting works.