I understand that all custom painting should be done inside an override of paintComponent(Graphics g)...
I have a GUI class which extends JFrame. It is essentially a google earth-like map app, and I want to have a mini map showing the current position, like in video games. I intend to do this by painting on the graphics context of the JLabel containing the image of the mini map.
If I redefine paintComponent(Graphics g) in the body of the class, I am not dealing with the graphics context of the JLabel, which is instantiated inside the class. I want to paint on the label, not on the window overall.
I could call Jlabel.getGraphics() and then draw on that but I gather that this is not a good way of doing it.
Inherit from JLabel and override its paintComponent and do your custom drawing in there. Be sure to call the super.paintComponent() as your first statement in your custom method. However, from what you say it sounds like what you should do is to replace the JLabel with a JPanel instead, and just draw your graphics and text in it (using the same approach discussed above). HTH
"What you are good at is not as important as being good at something." --Robert B.Parker