문제

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?
도움이 되었습니까?

해결책

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) {}
});

다른 팁

Use

splitter.addPropertyChangeListener("dividerLocation", myListener);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top