JSpltPane - detecting divider movement issued by the user?

A

Andreas Thiele

I'd like to know if the divider line was moved by the user. Installing a
PropertyChangeListener on JSplitPane.DIVIDER_LOCATION_PROPERTY does not
solve the problem because this event is also fired when the user resizes the
container so that the divider would be outside the container. In this case
the divider is automatically moved to fullfil the minimum size and
"dividerLocation" PropertyChange event gets fired.

Is there any chance to catch something like a divider drag end event?

Andreas
 
B

Bart Cremers

If the used l&f uses a SplitPaneUI extending from BasicSplitPaneUI, you
could add a MouseMotionListener to the divider you can get from the
BasicSplitPaneUI:

SplitPaneUI ui = split.getUI();
if (ui instanceof BasicSplitPaneUI) {
BasicSplitPaneUI basicUI = (BasicSplitPaneUI) ui;
basicUI.getDivider().addMouseMotionListener(new
MouseMotionListener() {
public void mouseDragged(MouseEvent e) {
System.out.println("DividerTest.mouseDragged");
}

public void mouseMoved(MouseEvent e) {
}
});
}

You can work from there on.

If not, you'll have to check on working directly on that UI and else
you're out of luck

Regards,

Bart
 
A

Andreas Thiele

Bart Cremers said:
If the used l&f uses a SplitPaneUI extending from BasicSplitPaneUI, you
could add a MouseMotionListener to the divider you can get from the
BasicSplitPaneUI:
...

Exactly what I need. I already was searching in this direction but didn't
notice basicUI.getDivider().

Thanks, a great help.

Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,079
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top