How to set an absolute position to a non-null layout Component in Java Swing?

I am writing a main menu for my Java Swing application, I want it to have 3 options: "New Game", "High Scores", "Exit" and a background image. I created a JPanel, for these 3 buttons and a JLabel with some title(i.e "Main Menu"). JLayeredPane seems to be the best choice for making a menu with a background image, so I decided to implement it, and this is where my problem comes up.

As I understood by reading the JLayeredPane docs, it can have only 1 Layout type. I imagined doing it by giving my JPanel - the one with buttons and a label - a GridBagLayout and giving my other JPanel with background image an absolute position. But how can I do it if giving an absolute position to an object requires having Layout set to null?

Thanks in advance!

Read more here:

Content Attribution

This content was originally published by olimpiabaku at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: