// 添加监视器
this.addPropertyChangeListener("dividerLocation",
new MainPanelPropertyChangeListener());
// 监视器的实现类
public class MainPanelPropertyChangeListener implements PropertyChangeListener {
@Override
public void propertyChange(PropertyChangeEvent evt) {
/*
* 记录主面板中分隔条的位置
*/
recordDividerLocation(evt);
}
public void recordDividerLocation(PropertyChangeEvent evt) {
MainPanelImpl mainPanelImpl = (MainPanelImpl) evt.getSource();
int width = mainPanelImpl.getWidth();
int location = (int)evt.getNewValue();
double proportionalLocation = location / (double)width;
MainPanelInitInfo mainPanelInitInfo = mainPanelImpl
.getMainPanelInitInfo();
mainPanelInitInfo.setLocation(location);
mainPanelInitInfo.setProportionalLocation(proportionalLocation);
}
}