aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How add comp to frame so x,y pos and height never changes, width does adjust? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How add comp to frame so x,y pos and height never changes, width does adjust?" Watch "How add comp to frame so x,y pos and height never changes, width does adjust?" New topic
Author

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

Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
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

Joined: Oct 18, 2000
Posts: 4121

Use a JPanel with BorderLayout, add the top component to BorderLayout.NORTH, and the rest to another JPanel at BorderLayout.CENTER.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How add comp to frame so x,y pos and height never changes, width does adjust?
 
Similar Threads
Frank ! Any answers?
determine with
Location and bounds of a component object
Resize components inside a JPane when using Null Layout
Resize JFrame to fit image