javax.swing.plaf.metal
Class MetalRootPaneUI.MouseInputHandler

java.lang.Object
  extended byjavax.swing.plaf.metal.MetalRootPaneUI.MouseInputHandler
All Implemented Interfaces:
EventListener, MouseInputListener, MouseListener, MouseMotionListener
Enclosing class:
MetalRootPaneUI

private class MetalRootPaneUI.MouseInputHandler
extends Object
implements MouseInputListener

MouseInputHandler is responsible for handling resize/moving of the Window. It sets the cursor directly on the Window when then mouse moves over a hot spot.


Field Summary
private  int dragCursor
          Used to determine the corner the resize is occuring from.
private  int dragHeight
          Height of the window when the drag started.
private  int dragOffsetX
          X location the mouse went down on for a drag operation.
private  int dragOffsetY
          Y location the mouse went down on for a drag operation.
private  int dragWidth
          Width of the window when the drag started.
private  boolean isMovingWindow
          Set to true if the drag operation is moving the window.
 
Constructor Summary
private MetalRootPaneUI.MouseInputHandler()
           
 
Method Summary
private  void adjust(Rectangle bounds, Dimension min, int deltaX, int deltaY, int deltaWidth, int deltaHeight)
           
private  int calculateCorner(Component c, int x, int y)
          Returns the corner that contains the point x, y, or -1 if the position doesn't match a corner.
private  int calculatePosition(int spot, int width)
          Returns an integer indicating the position of spot in width.
private  int getCursor(int corner)
          Returns the Cursor to render for the specified corner.
 void mouseClicked(MouseEvent ev)
          Invoked when the mouse button has been clicked (pressed and released) on a component.
 void mouseDragged(MouseEvent ev)
          Invoked when a mouse button is pressed on a component and then dragged.
 void mouseEntered(MouseEvent ev)
          Invoked when the mouse enters a component.
 void mouseExited(MouseEvent ev)
          Invoked when the mouse exits a component.
 void mouseMoved(MouseEvent ev)
          Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed.
 void mousePressed(MouseEvent ev)
          Invoked when a mouse button has been pressed on a component.
 void mouseReleased(MouseEvent ev)
          Invoked when a mouse button has been released on a component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isMovingWindow

private boolean isMovingWindow
Set to true if the drag operation is moving the window.


dragCursor

private int dragCursor
Used to determine the corner the resize is occuring from.


dragOffsetX

private int dragOffsetX
X location the mouse went down on for a drag operation.


dragOffsetY

private int dragOffsetY
Y location the mouse went down on for a drag operation.


dragWidth

private int dragWidth
Width of the window when the drag started.


dragHeight

private int dragHeight
Height of the window when the drag started.

Constructor Detail

MetalRootPaneUI.MouseInputHandler

private MetalRootPaneUI.MouseInputHandler()
Method Detail

mousePressed

public void mousePressed(MouseEvent ev)
Description copied from interface: MouseListener
Invoked when a mouse button has been pressed on a component.

Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent ev)
Description copied from interface: MouseListener
Invoked when a mouse button has been released on a component.

Specified by:
mouseReleased in interface MouseListener

mouseMoved

public void mouseMoved(MouseEvent ev)
Description copied from interface: MouseMotionListener
Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed.

Specified by:
mouseMoved in interface MouseMotionListener

adjust

private void adjust(Rectangle bounds,
                    Dimension min,
                    int deltaX,
                    int deltaY,
                    int deltaWidth,
                    int deltaHeight)

mouseDragged

public void mouseDragged(MouseEvent ev)
Description copied from interface: MouseMotionListener
Invoked when a mouse button is pressed on a component and then dragged. MOUSE_DRAGGED events will continue to be delivered to the component where the drag originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).

Due to platform-dependent Drag&Drop implementations, MOUSE_DRAGGED events may not be delivered during a native Drag&Drop operation.

Specified by:
mouseDragged in interface MouseMotionListener

mouseEntered

public void mouseEntered(MouseEvent ev)
Description copied from interface: MouseListener
Invoked when the mouse enters a component.

Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent ev)
Description copied from interface: MouseListener
Invoked when the mouse exits a component.

Specified by:
mouseExited in interface MouseListener

mouseClicked

public void mouseClicked(MouseEvent ev)
Description copied from interface: MouseListener
Invoked when the mouse button has been clicked (pressed and released) on a component.

Specified by:
mouseClicked in interface MouseListener

calculateCorner

private int calculateCorner(Component c,
                            int x,
                            int y)
Returns the corner that contains the point x, y, or -1 if the position doesn't match a corner.


getCursor

private int getCursor(int corner)
Returns the Cursor to render for the specified corner. This returns 0 if the corner doesn't map to a valid Cursor


calculatePosition

private int calculatePosition(int spot,
                              int width)
Returns an integer indicating the position of spot in width. The return value will be: 0 if < BORDER_DRAG_THICKNESS 1 if < CORNER_DRAG_WIDTH 2 if >= CORNER_DRAG_WIDTH && < width - BORDER_DRAG_THICKNESS 3 if >= width - CORNER_DRAG_WIDTH 4 if >= width - BORDER_DRAG_THICKNESS 5 otherwise