javax.swing.plaf.basic
protected class: BasicSplitPaneDivider.MouseHandler [javadoc |
source]
java.lang.Object
java.awt.event.MouseAdapter
javax.swing.plaf.basic.BasicSplitPaneDivider$MouseHandler
All Implemented Interfaces:
MouseMotionListener, MouseListener, MouseWheelListener
MouseHandler is responsible for converting mouse events
(released, dragged...) into the appropriate DragController
methods.
| Methods from java.lang.Object: |
|---|
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from javax.swing.plaf.basic.BasicSplitPaneDivider$MouseHandler Detail: |
public void mouseDragged(MouseEvent e) {
if (dragger != null) {
if (e.getSource() == splitPane) {
dragger.continueDrag(e.getX(), e.getY());
}
else if (e.getSource() == BasicSplitPaneDivider.this) {
Point ourLoc = getLocation();
dragger.continueDrag(e.getX() + ourLoc.x,
e.getY() + ourLoc.y);
}
else if (e.getSource() == hiddenDivider) {
Point hDividerLoc = hiddenDivider.getLocation();
int ourX = e.getX() + hDividerLoc.x;
int ourY = e.getY() + hDividerLoc.y;
dragger.continueDrag(ourX, ourY);
}
e.consume();
}
}
If dragger is not null it is messaged with continueDrag. |
public void mouseEntered(MouseEvent e) {
if (e.getSource() == BasicSplitPaneDivider.this) {
setMouseOver(true);
}
}
Invoked when the mouse enters a component. |
public void mouseExited(MouseEvent e) {
if (e.getSource() == BasicSplitPaneDivider.this) {
setMouseOver(false);
}
}
Invoked when the mouse exits a component. |
public void mouseMoved(MouseEvent e) {
}
Resets the cursor based on the orientation. |
public void mousePressed(MouseEvent e) {
if ((e.getSource() == BasicSplitPaneDivider.this ||
e.getSource() == splitPane) &&
dragger == null &&splitPane.isEnabled()) {
Component newHiddenDivider = splitPaneUI.
getNonContinuousLayoutDivider();
if (hiddenDivider != newHiddenDivider) {
if (hiddenDivider != null) {
hiddenDivider.removeMouseListener(this);
hiddenDivider.removeMouseMotionListener(this);
}
hiddenDivider = newHiddenDivider;
if (hiddenDivider != null) {
hiddenDivider.addMouseMotionListener(this);
hiddenDivider.addMouseListener(this);
}
}
if (splitPane.getLeftComponent() != null &&
splitPane.getRightComponent() != null) {
if (orientation == JSplitPane.HORIZONTAL_SPLIT) {
dragger = new DragController(e);
}
else {
dragger = new VerticalDragController(e);
}
if (!dragger.isValid()) {
dragger = null;
}
else {
prepareForDragging();
dragger.continueDrag(e);
}
}
e.consume();
}
}
Starts the dragging session by creating the appropriate instance
of DragController. |
public void mouseReleased(MouseEvent e) {
if (dragger != null) {
if (e.getSource() == splitPane) {
dragger.completeDrag(e.getX(), e.getY());
}
else if (e.getSource() == BasicSplitPaneDivider.this) {
Point ourLoc = getLocation();
dragger.completeDrag(e.getX() + ourLoc.x,
e.getY() + ourLoc.y);
}
else if (e.getSource() == hiddenDivider) {
Point hDividerLoc = hiddenDivider.getLocation();
int ourX = e.getX() + hDividerLoc.x;
int ourY = e.getY() + hDividerLoc.y;
dragger.completeDrag(ourX, ourY);
}
dragger = null;
e.consume();
}
}
If dragger is not null it is messaged with completeDrag. |