This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Image lost behind buttons

 
Mike Lipay
Ranch Hand
Posts: 171
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2475
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike,
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.

http://faq.javaranch.com/java/CarefullyChooseOneForum
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic