wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes JScrollPane Weight Shift In GridBagLayout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollPane Weight Shift In GridBagLayout" Watch "JScrollPane Weight Shift In GridBagLayout" New topic

JScrollPane Weight Shift In GridBagLayout

Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 190

The problem with this layout has to do with the JScrollPane which is on the third (cell 5) last cell in the grid. When text is appended to the JTextArea within the JScrollPane, the weight of the JScrollPane expands, thus pushing downward the two items in the last two cells. The lowermost cell is a JLabel for status messages. When text is removed from the JTextArea, the JScrollPane once again changes size, and the the components below move upward to fill the space. I am trying to find a way to the keep the lower half of the layout from shifting regardless of how much text is appended to the JTextArea. I have tried setting the JScrollPane with the constant JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, but it makes no difference.

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2153
To increase your chances of getting help you should create a SSCCE, that demonstrates the incorrect behaviour.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Look at your gridweighty when adding this.clear, bottom and this.status
Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 190

Ok Mark, I took your advice and configured the following 2 items as you see below adding the weighty configuration. The JSrollPane no longer resizes when text is appended or removed. Thanks for your advice.

I agree. Here's the link: http://aspose.com/file-tools
subject: JScrollPane Weight Shift In GridBagLayout
Similar Threads
text box - GridBagLayout
Markov Model Close to being complete but needs a little help
GridBagLayout:: a few Qs
Implement this constructor
how to fix the JLabel Text value in Swings