The moose likes Swing / AWT / SWT and the fly likes Image lost behind buttons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Image lost behind buttons" Watch "Image lost behind buttons" New topic

Image lost behind buttons

Mike Lipay
Ranch Hand

Joined: Sep 11, 2007
Posts: 171
Class has moved onto adding buttons onto the window. Just prior to this we learnt to add an image via JComponent, then we added buttons onto a JPanel; the problem is that when I try to combine the two into a single window (my own desire, not part of the class) I completely lose whatever is added first. How can I add the buttons so that both the button and the graphic are visible (buttons on top of the graphic)?

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2454
I completely lose whatever is added first

Read the section from the Swing tutorial on Using Layout Managers.

The default layout manager for a frame is the BorderLayout. Where do components get added when you don't specify a constraint? What do you think happens when you try to add two components at the same place?

Either use proper constraints or use a different layout manager.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10836

As you already know we have a forum dedicated for Swing. This question would have been more suitable there.
I will move it there for you.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
I agree. Here's the link:
subject: Image lost behind buttons
It's not a secret anymore!