I have 3 Jpanels nested like the following:
main JPanel
{
second JPanel {}
3rd JPanel {}
main method
}
This is the order I have added them in the 'main panel' :
add(thirdPanel);
add(secondPanel);
setComponentZOrder(componentsPanel, 0);
setComponentZOrder(panel, 1);
The second and third panels both have paintComponent
methods and initially the thirdPanel which contains GUI components such as buttons
etc. is on top of the secondPanel (which is what I want) but whenever I draw or repaint
in the secondPanel, all the components in thirdPanel are hidden beneath the secondPanel. It's like secondPanel is taking priority. I basically want the thirdPanel to stay on top no matter what.
Note: I am using a null layout manager.