|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.awt.event.MouseAdapter
com.wordpress.tipsforjava.swing.ComponentResizer
public class ComponentResizer extends MouseAdapter
The ComponentResizer allows you to resize a component by dragging a border of the component.
| Field Summary | |
|---|---|
protected static int |
EAST
|
private static Dimension |
MAXIMUM_SIZE
|
private static Dimension |
MINIMUM_SIZE
|
protected static int |
NORTH
|
protected static int |
SOUTH
|
protected static int |
WEST
|
private boolean |
autoscrolls
|
private Rectangle |
bounds
|
private static Map |
cursors
|
private int |
direction
|
private Insets |
dragInsets
|
private Dimension |
maximumSize
|
private Dimension |
minimumSize
|
private Point |
pressed
|
private boolean |
resizing
|
private Dimension |
snapSize
|
private Cursor |
sourceCursor
|
| Constructor Summary | |
ComponentResizer()
Convenience contructor. |
|
ComponentResizer(Component... components)
Convenience contructor. |
|
ComponentResizer(Insets dragInsets, Component... components)
Convenience contructor. |
|
ComponentResizer(Insets dragInsets, Dimension snapSize, Component... components)
Create a ComponentResizer. |
|
| Method Summary | |
|---|---|
protected void
|
changeBounds(Component source, int direction, Rectangle bounds, Point pressed, Point current)
|
void
|
deregisterComponent(Component... components)
Remove listeners from the specified component |
private Dimension
|
getBoundingSize(Component source)
|
private int
|
getDragBounded(int drag, int snapSize, int dimension, int minimum, int maximum)
|
private int
|
getDragDistance(int larger, int smaller, int snapSize)
|
Insets
|
getDragInsets()
Get the drag insets |
Dimension
|
getMaximumSize()
Get the components maximum size. |
Dimension
|
getMinimumSize()
Get the components minimum size. |
Dimension
|
getSnapSize()
Get the snap size. |
void
|
mouseDragged(MouseEvent e)
Resize the component ensuring location and size is within the bounds of the parent container and that the size is within the minimum and maximum constraints. |
void
|
mouseEntered(MouseEvent e)
|
void
|
mouseExited(MouseEvent e)
|
void
|
mouseMoved(MouseEvent e)
|
void
|
mousePressed(MouseEvent e)
|
void
|
mouseReleased(MouseEvent e)
Restore the original state of the Component |
void
|
registerComponent(Component... components)
Add the required listeners to the specified component |
void
|
setDragInsets(Insets dragInsets)
Set the drag dragInsets. |
void
|
setMaximumSize(Dimension maximumSize)
Specify the maximum size for the component. |
void
|
setMinimumSize(Dimension minimumSize)
Specify the minimum size for the component. |
void
|
setSnapSize(Dimension snapSize)
Control how many pixels a border must be dragged before the size of the component is changed. |
private void
|
validateMinimumAndInsets(Dimension minimum, Insets drag)
When the components minimum size is less than the drag insets then we can't determine which border should be resized so we need to prevent this from happening. |
| 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 |
|---|
protected static final int EAST
private static final Dimension MAXIMUM_SIZE
private static final Dimension MINIMUM_SIZE
protected static final int NORTH
protected static final int SOUTH
protected static final int WEST
private boolean autoscrolls
private Rectangle bounds
private static Map cursors
private int direction
private Insets dragInsets
private Dimension maximumSize
private Dimension minimumSize
private Point pressed
private boolean resizing
private Dimension snapSize
private Cursor sourceCursor
| Constructor Detail |
|---|
public ComponentResizer()
public ComponentResizer(Component... components)
components - components to be automatically registered
public ComponentResizer(Insets dragInsets, Component... components)
dragInsets - Insets specifying which borders are eligible to be
resized.components - components to be automatically registered
public ComponentResizer(Insets dragInsets, Dimension snapSize, Component... components)
dragInsets - Insets specifying which borders are eligible to be
resized.snapSize - Specify the dimension to which the border will snap to
when being dragged. Snapping occurs at the halfway mark.components - components to be automatically registered
| Method Detail |
|---|
protected void changeBounds(Component source, int direction, Rectangle bounds, Point pressed, Point current)
public void deregisterComponent(Component... components)
component - the component the listeners are removed from
private Dimension getBoundingSize(Component source)
private int getDragBounded(int drag, int snapSize, int dimension, int minimum, int maximum)
private int getDragDistance(int larger, int smaller, int snapSize)
public Insets getDragInsets()
public Dimension getMaximumSize()
public Dimension getMinimumSize()
public Dimension getSnapSize()
de public public void mouseDragged(MouseEvent e)
de public public void mouseEntered(MouseEvent e)
de public public void mouseExited(MouseEvent e)
de public public void mouseMoved(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 setDragInsets(Insets dragInsets)
dragInsets - Insets to control which borders are resizeable.
public void setMaximumSize(Dimension maximumSize)
maximumSize - the maximum size for a component.
public void setMinimumSize(Dimension minimumSize)
minimumSize - the minimum size for a component.
public void setSnapSize(Dimension snapSize)
snapSize - Dimension object allows you to separately spcify a
horizontal and vertical snap size.
private void validateMinimumAndInsets(Dimension minimum, Insets drag)
Groovy Documentation