I am trying to implement a JSplitPane that saves its state to some configuration file, so i added a listener like this one :
mHorSplitPane.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent changeEvent) {
JSplitPane sourceSplitPane = (JSplitPane) changeEvent.getSource();
String propertyName = changeEvent.getPropertyName();
if (propertyName.equals(JSplitPane.DIVIDER_LOCATION_PROPERTY)) {
mController.writeSplitPaneProperty((int) (sourceSplitPane.getDividerLocation()/(float)sourceSplitPane.getBounds().width*100));
}
}
});
which handles it just fine, but for some reason sometimes Swing code itself changes this property and changes the divider location, any suggestion on how can i overcome this?