• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How add comp to frame so x,y pos and height never changes, width does adjust?

 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to have a component at the top of a frame that never moves from the 0,0 position and it's height is always 20px tall. The component should get wider when the frame is expanded. Also, whatever components are below this one (on the frame) should expand as normal (i.e. relatively). Does anyone know how I would achieve this?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a JPanel with BorderLayout, add the top component to BorderLayout.NORTH, and the rest to another JPanel at BorderLayout.CENTER.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic