Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can I setWidth and setHeight for JPanel?  RSS feed

 
suraya ya'acob
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can I setWidth and setHeight for JPanel?
and the i want to use Button Scroll to manipulate that panel.
Can anybody show me some example on this?
Thank you
 
kyle amburn
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set the Size using one of the following methods:
setPreferredSize(Dimension)
setSize(Dimension)
However, it will only change if the layout manager of the Container that houses the JPanel will allow it. Most layout managers conserve space around the items in the JPanel and will therefore fill only the minimum space based on its components.
If you want a layout manager that will allow you to change the size reliably, you need to use a pixel based layout manager. If you need access to a pixel based layout manager, email me and I will send you one of mine.
Kyle
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!