public class ComponentMover extends MouseAdapter
Constructor and Description |
---|
ComponentMover()
Constructor for moving individual components.
|
ComponentMover(Class destinationClass,
Component... components)
Constructor to specify a Class of Component that will be moved when
drag events are generated on a registered child component.
|
ComponentMover(Component destinationComponent,
Component... components)
Constructor to specify a parent component that will be moved when drag
events are generated on a registered child component.
|
Modifier and Type | Method and Description |
---|---|
void |
deregisterComponent(Component... components)
Remove listeners from the specified component
|
Insets |
getDragInsets()
Get the drag insets
|
Dimension |
getSnapSize()
Get the snap size
|
boolean |
isChangeCursor()
Get the change cursor property
|
void |
mouseDragged(MouseEvent e)
Move the component to its new location.
|
void |
mousePressed(MouseEvent e)
Setup the variables used to control the moving of the component:
source - the source component of the mouse event
destination - the component that will ultimately be moved
pressed - the Point where the mouse was pressed in the destination
component coordinates.
|
void |
mouseReleased(MouseEvent e)
Restore the original state of the Component
|
void |
registerComponent(Component... components)
Add the required listeners to the specified component
|
void |
setChangeCursor(boolean changeCursor)
Set the change cursor property
|
void |
setDragInsets(Insets dragInsets)
Set the drag insets.
|
void |
setSnapSize(Dimension snapSize)
Set the snap size.
|
mouseClicked, mouseEntered, mouseExited, mouseMoved, mouseWheelMoved
public ComponentMover()
public ComponentMover(Class destinationClass, Component... components)
destinationClass
- the Class of the ancestor componentcomponents
- the Components to be registered for forwarding
drag events to the ancestor Component.public ComponentMover(Component destinationComponent, Component... components)
destinationComponent
- the component drage events should be forwareded tocomponents
- the Components to be registered for forwarding drag
events to the parent component to be movedpublic boolean isChangeCursor()
public void setChangeCursor(boolean changeCursor)
changeCursor
- when true the cursor will be changed to the
Cursor.MOVE_CURSOR while the mouse is pressedpublic Insets getDragInsets()
public void setDragInsets(Insets dragInsets)
dragInsets
- public void deregisterComponent(Component... components)
components
- components the listeners are removed frompublic void registerComponent(Component... components)
components
- components the listeners are added topublic Dimension getSnapSize()
public void setSnapSize(Dimension snapSize)
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
mousePressed
in class MouseAdapter
public void mouseDragged(MouseEvent e)
mouseDragged
in interface MouseMotionListener
mouseDragged
in class MouseAdapter
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
mouseReleased
in class MouseAdapter