• Post Reply Bookmark Topic Watch Topic
  • New Topic

GUI sizing  RSS feed

 
Jeff Powell
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing an interactive GUI but am having trouble getting each component the right size. I have tried setSize(), setBounds(), and still one component dwarfs the others. I have used these commands on a JFrame and they work fine. I try to use them on JPanels and I get no results. Is there a way to set a JPanel to a certain location and size?

Thanks
jeff
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeff,

Welcome to JavaRanch!

You need to learn about layout managers. It's not something you learn in five minutes, so take your time.

I'm going to move this to our Swing/AWT forum, where it is on-topic. We can continue the discussion there.
 
Pat Hays
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Jeff

Try to use setPreferredSize(), setMaximumSize() or setMinimumSize() insteaded of setSize(), It will work as long as you are using a layout manager for the parent panel.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!