Reputation: 954
At the moment, I have two JPanel classes that draw images and shapes to a JFrame (I will have more in the future), I'm doing this to make things organised.
At first I tried to add each JPanel to the JFrame, but one JPanel would paint over the other.
Each class should be able to call other classes that may draw images to screen as well.
The problem I have is that I cannot get them to draw to the screen.
Should I use paintComponent
or paintAll
? And how should they be used?
Thank you for any help :)
Upvotes: 0
Views: 981
Reputation: 159754
It sounds as though you are adding both panels to the same location in the JFrame
probably in the BorderLayout.CENTER
position. One solution is to use a GridLayout
with 2 columns for the JFrame
and add the 2 panels.
paintComponent
is the correct method to override in your panels.
Follow the custom painting trail to see how it should be used.
Upvotes: 2