I want to set a background image for my JPannel
which contains many JTextField
and JButton
(I used g.drawImage()
), but the the components won't appear unless the mouse passes by.
I can't make a JPanel
for every component because I have too many of them.
Can anyone please help or point me into the right direction?
It sounds like either you've overridden paint
or failed to call super.paintComponent
when painting your image.
Make sure that:
paintComponent
of your JPanel
super.paintComponent
before you perform any custom paintingFor example
Also take a look at Painting in AWT and Swing and Performing Custom Painting for more details about painting in Swing