• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Image lost behind buttons

 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)?

 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic