How do I make the menu bar accessible if i'm using the glass pane

B

BugFree

Hi I'm trying to create a program that uses a image as a background.
When i figured out how to set the image to the background of the gui it
wouldn't let me place buttons or textfields on top of it. This is how i
did it...

((JPanel)getContentPane()).setOpaque(false);
ImageIcon image = new ImageIcon("usamap.gif");
JLabel backlabel = new JLabel(image);
getLayeredPane().add(backlabel, new Integer(Integer.MIN_VALUE));
backlabel.setBounds(0,0,image.getIconWidth(), image.getIconHeight());

This way I was unable to place the buttons i needed over top. So I
tried to use the glass pane for that which worked but now my menu bar
does not respond. Any ideas on how I could fix this problem or a
better way to place the image in the background and still use buttons
on it would be greatly apreciated.

Thanks
 
M

Monique Y. Mudama

Hi I'm trying to create a program that uses a image as a background.
When i figured out how to set the image to the background of the gui it
wouldn't let me place buttons or textfields on top of it. This is how i
did it...

((JPanel)getContentPane()).setOpaque(false);
ImageIcon image = new ImageIcon("usamap.gif");
JLabel backlabel = new JLabel(image);
getLayeredPane().add(backlabel, new Integer(Integer.MIN_VALUE));
backlabel.setBounds(0,0,image.getIconWidth(), image.getIconHeight());

This way I was unable to place the buttons i needed over top. So I
tried to use the glass pane for that which worked but now my menu bar
does not respond. Any ideas on how I could fix this problem or a
better way to place the image in the background and still use buttons
on it would be greatly apreciated.

I've never used it, but what about the OverlayLayout?

http://www.java2s.com/Code/Java/Swing-JFC/AtestoftheOverlayLayoutmanagerallowingexperimentation.htm
 
B

BugFree

I don't really know anything about the overlay layout i'm not sure i
know how to use it but i'll give it a try

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top