Holger's Java API

## com.antelmann.util.gui
Class MouseBoundsListener

    java.lang.Object
      java.awt.event.MouseAdapter
          com.antelmann.util.gui.MouseBoundsListener

All Implemented Interfaces:
  MouseListener, MouseMotionListener, MouseWheelListener, EventListener, MouseInputListener

    public class MouseBoundsListener

extends MouseAdapter
implements MouseInputListener

a listener class for moving/resizing a component via mouse movements. For proper functionality, the MouseBoundsListener must be registered with the component as both, MouseListener and MouseMotionListener. Note: the resizing doesn't quite work, yet; this class is currently limited to moving a component.

Author:
  Holger Antelmann

Nested Class Summary
`static interface` `MouseBoundsListener.Snapper`

Constructor Summary
`MouseBoundsListener(Component c)`
`MouseBoundsListener(Component c, Container parent)`
`MouseBoundsListener(Component c, Container parent, MouseBoundsListener.Snapper snapper, boolean continuousSnapping)`
`MouseBoundsListener(Component c, MouseBoundsListener.Snapper snapper)`
`MouseBoundsListener(Component c, MouseBoundsListener.Snapper snapper, boolean continuousSnapping)`

Method Summary
`Rectangle` `getDragOrigin()` returns the bounds from where the component is dragged or null if the component is currently not dragged
`Insets` `getInsets()` defines the tolerance for resizing versus moving if a drag at the edge of the component occurs; 2 pixels on every edge by default
`Container` `getParent()`
`MouseBoundsListener.Snapper` `getSnapper()`
`boolean` `isContinuousSnapping()`
`void` `mouseDragged(MouseEvent ev)`
`void` `mouseMoved(MouseEvent ev)`
`void` `mousePressed(MouseEvent ev)`
`void` `mouseReleased(MouseEvent ev)` checks whether there are any limits on the drag target and then snaps to the given bounds
`void` `setContinuousSnapping(boolean flag)`
`void` `setInsets(Insets insets)`
`void` `setParent(Container parent)`
`void` `setSnapper(MouseBoundsListener.Snapper snapper)` defines the snapping behavior while dragging this component

Methods inherited from class java.awt.event.MouseAdapter
`mouseClicked, mouseEntered, mouseExited, mouseWheelMoved`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface java.awt.event.MouseListener
`mouseClicked, mouseEntered, mouseExited`

Constructor Detail

### MouseBoundsListener

    public MouseBoundsListener(Component c)

### MouseBoundsListener

    public MouseBoundsListener(Component c,
                               Container parent)

### MouseBoundsListener

    public MouseBoundsListener(Component c,
                               MouseBoundsListener.Snapper snapper)

### MouseBoundsListener

    public MouseBoundsListener(Component c,
                               MouseBoundsListener.Snapper snapper,
                               boolean continuousSnapping)

### MouseBoundsListener

    public MouseBoundsListener(Component c,
                               Container parent,
                               MouseBoundsListener.Snapper snapper,
                               boolean continuousSnapping)

Method Detail

### getDragOrigin

    public Rectangle getDragOrigin()

  returns the bounds from where the component is dragged or null if the component is currently not dragged

### getParent

    public Container getParent()

### setParent

    public void setParent(Container parent)

### setSnapper

    public void setSnapper(MouseBoundsListener.Snapper snapper)

  defines the snapping behavior while dragging this component

### getSnapper

    public MouseBoundsListener.Snapper getSnapper()

### isContinuousSnapping

    public boolean isContinuousSnapping()

### setContinuousSnapping

    public void setContinuousSnapping(boolean flag)

### getInsets

    public Insets getInsets()

  defines the tolerance for resizing versus moving if a drag at the edge of the component occurs; 2 pixels on every edge by default

### setInsets

    public void setInsets(Insets insets)

### mouseDragged

    public void mouseDragged(MouseEvent ev)

  Specified by:
    `mouseDragged` in interface `MouseMotionListener`
  Overrides:
    `mouseDragged` in class `MouseAdapter`

### mouseMoved

    public void mouseMoved(MouseEvent ev)

  Specified by:
    `mouseMoved` in interface `MouseMotionListener`
  Overrides:
    `mouseMoved` in class `MouseAdapter`

### mousePressed

    public void mousePressed(MouseEvent ev)

  Specified by:
    `mousePressed` in interface `MouseListener`
  Overrides:
    `mousePressed` in class `MouseAdapter`

### mouseReleased

    public void mouseReleased(MouseEvent ev)

  checks whether there are any limits on the drag target and then snaps to the given bounds

  Specified by:
    `mouseReleased` in interface `MouseListener`
  Overrides:
    `mouseReleased` in class `MouseAdapter`
  See Also:
    `MouseBoundsListener.Snapper.snapTo(MouseBoundsListener, Rectangle, boolean)`

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads