• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Resizing in JSplitPane

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am using a JSplitPane (HORIZONTAL split) to hold a JTree on the left and a JPanel containing a JList and JTable side by side on the right.
When I try to resize the JSplitPane using the divider, I cannot pull it to the left, only to the right. That is, I cannot reduce the size of the panel on the RIGHT side of the JSplitPane!
Can anyone tell me why this happens? I am fairly sure that I have not set any max/min or preferred sizes for any of the components on the RIGHT so why can't I make them smaller using the JSplitPane divider???

Please help,
Thanks in advance,
Alex
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem you are having is due to the natural behavior of JSplitPane. From the JAVA 2 API docs:
When the user is resizing the Components the minimum size of the Components is used to determine the maximum/minimum position the Components can be set to. If the minimum size of the two components is greater than the size of the split pane the divider will not allow you to resize it. To alter the minimum size of a JComponent, see JComponent.setMinimumSize(java.awt.Dimension).
When the user resizes the split pane the new space is distributed between the two components based on the resizeWeight property. A value of 0, the default, indicates the right/bottom component gets all the space, where as a value of 1 indicates the left/top component gets all the space.
You could use a PropertyChangeListener and BasicSplitPaneDivider to code in the behavior you want.
Hope this is helpful
 
alex earnshaw
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a million, I used setMinimumSize to set the min size of the panel on the right, and PropertyChangeListener to detect when the divider was moved...it worked a dream
thanks
Alex
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic