有没有办法检测何时移动JSplitPane分隔符?有没有办法添加分频器运动的监听器?
JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,panel1,panel2); // What do I put here to be notified if the divider in sp is moved?
解决方法
我想你正在从容器寻找
addPropertyChangeListener.这样的东西
sp.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent pce) {} });