• 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:

JSplitPane and its setDividerLocation method

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am having BIG problems with a JSplitPane and its setDividerLocation method, it is not working the way it should.
I have a JSplitPane with a Horizontal split. Once it is created, I try to dinamically change the size of the right component, but I need for the divider to stay at the location it was before I changed the size of the right component, so before I change the size I get the dividerLocation, store it, and at the end, tell the splitPane to place the divider again at that location by using its setDividerLocation method, and it just won't work, the split pane will move the divider to the right, making the left component bigger.
The resizeWeight shouldn't matter since I am telling the divider to be placed at a specific location, anybody know if this is common or if I am doing something wrong?
Thanks
 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you might check to make sure that the dividerLocation is measuring from the left side.
Also, why not use the resizeWeight?
Have any of the code to show us?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using this code to test out JSplitPane behavior...



It looks like the default behavior of JSplitPane is to stay the same size even when it's components change size... I had to call resetToPreferredSizes() to get the splitpane to honour the new sizes of the components. Also, setPrefferedSizes() looks like it does the preferred size of the left component first, then the right component gets the rest of the split pane, so if you have a 100 pixel split pane, and you set the preferred size of the left component to 10, and the preferred size of the right component to 10, you'll end up with a 10 pixel left component, and a 90 pixel ( minus the divider ) right component.

I'm not sure why you're having problems with components size changes changing the location of the divider... by default JSplitPane should be doing what you want and you shouldn't have to save the location of the slider at all...

Could you post some code of what you are trying to do?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic