|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.awt.event.MouseAdapter
com.wordpress.tipsforjava.swing.ComponentMover
public class ComponentMover extends MouseAdapter
This class allows you to move a Component by using a mouse. The Component moved can be a high level Window (ie. Window, Frame, Dialog) in which case the Window is moved within the desktop. Or the Component can belong to a Container in which case the Component is moved within the Container. When moving a Window, the listener can be added to a child Component of the Window. In this case attempting to move the child will result in the Window moving. For example, you might create a custom "Title Bar" for an undecorated Window and moving of the Window is accomplished by moving the title bar only. Multiple components can be registered as "window movers". Components can be registered when the class is created. Additional components can be added at any time using the registerComponent() method.
| Field Summary | |
|---|---|
private boolean |
autoscrolls
|
private boolean |
changeCursor
|
private Component |
destination
|
private Class |
destinationClass
|
private Component |
destinationComponent
|
private Insets |
dragInsets
|
private Point |
location
|
private Cursor |
originalCursor
|
private Point |
pressed
|
private Dimension |
snapSize
|
private Component |
source
|
| Constructor Summary | |
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. |
|
| Method Summary | |
|---|---|
void
|
deregisterComponent(Component... components)
Remove listeners from the specified component |
private int
|
getDragDistance(int larger, int smaller, int snapSize)
|
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: |
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. |
private void
|
setupForDragging(MouseEvent e)
|
| Methods inherited from class MouseAdapter | |
|---|---|
| mousePressed, mouseReleased, mouseClicked, mouseExited, mouseEntered, mouseMoved, mouseDragged, mouseWheelMoved, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
| Methods inherited from class Object | |
|---|---|
| wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
| Field Detail |
|---|
private boolean autoscrolls
private boolean changeCursor
private Component destination
private Class destinationClass
private Component destinationComponent
private Insets dragInsets
private Point location
private Cursor originalCursor
private Point pressed
private Dimension snapSize
private Component source
| Constructor Detail |
|---|
public ComponentMover()
public ComponentMover(Class destinationClass, Component... components)
destinationClass - the Class of the ancestor componentcomponent - 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 moved
| Method Detail |
|---|
public void deregisterComponent(Component... components)
component - the component the listeners are removed from
private int getDragDistance(int larger, int smaller, int snapSize)
public Insets getDragInsets()
public Dimension getSnapSize()
public boolean isChangeCursor()
de public public void mouseDragged(MouseEvent e)
de public public void mousePressed(MouseEvent e)
de public public void mouseReleased(MouseEvent e)
public void registerComponent(Component... components)
component - the component the listeners are added to
public void setChangeCursor(boolean changeCursor)
changeCursor - when true the cursor will be changed to the
Cursor.MOVE_CURSOR while the mouse is pressed
public void setDragInsets(Insets dragInsets)
public void setSnapSize(Dimension snapSize)
private void setupForDragging(MouseEvent e)
Groovy Documentation