gpt4 book ai didi

java - 检测 JSplitPane 分隔线移动

转载 作者:搜寻专家 更新时间:2023-10-30 19:52:02 25 4
gpt4 key购买 nike

有没有办法检测 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) {}
});

关于java - 检测 JSplitPane 分隔线移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14468648/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com