检测JSplitPane分频器运动 [英] Detecting JSplitPane Divider Movement
本文介绍了检测JSplitPane分频器运动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法可以检测到何时移动了JSplitPane分隔器?有没有一种方法可以为分隔线的移动添加侦听器?
Is there a way to detect when a JSplitPane divider is moved? Is there a way to add a listener for divider movement?
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 .像这样...
I think you're looking for addPropertyChangeListener from Container
. Something like this...
sp.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent pce) {}
});
这篇关于检测JSplitPane分频器运动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文