I have this code:
My question is:Code:
public class HelloWorld extends JComponent
public void paintComponent(Graphics g)
g.drawString("Hello!!!", 110, 110);
When I add this component to a frame, I get the text: "Hello!!!". However I am having a hard-time understanding what this Graphics g stand for.
paintComponent overrides the paintComponentMethod in JComponent,and is called automatically.
This method gets a parameter of type Graphics. So we have (Graphics g).
and then I call g.drawString
But what is this g here?
Please do not tell me to look to the API. I already have.
Graphics is an abstract class, so you can not create an object of Graphics right?
And I nowhere declared a reference g of type Graphics anyway?