I have a JFrame where it uses a background Image as the content pane. I successfully did it my having an ImagePanel class. However, when I try to add others components, these components do not show. I guess that it is about the Z order so I tried to set the Z order of the label but it gave me an error.
frame.setContentPane(new ImagePanel(bg));
frame.setBackground(new Color(0,255,0,0));
frame.getContentPane().setComponentZOrder(jLabel1, 1);
frame.setVisible(true);
The exception is:
java.lang.IllegalArgumentException: illegal component position
When I try to change the Z order to 0, it gives me a different error
frame.getContentPane().setComponentZOrder(jLabel1, 0);
the error is:
java.lang.IllegalArgumentException: component and container should be in the same top-level window