public class Resizable
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Resizable.ResizeCorner |
Modifier and Type | Field and Description |
---|---|
protected javax.swing.JComponent |
_component |
static int |
ALL |
static int |
LEFT |
static int |
LOWER |
static int |
LOWER_LEFT |
static int |
LOWER_RIGHT |
static int |
NONE |
static java.lang.String |
PROPERTY_RESIZABLE_CORNERS |
static java.lang.String |
PROPERTY_RESIZE_CORNER_SIZE |
static int |
RIGHT |
static int |
UPPER |
static int |
UPPER_LEFT |
static int |
UPPER_RIGHT |
Constructor and Description |
---|
Resizable(javax.swing.JComponent component)
Creates a new
Resizable . |
Modifier and Type | Method and Description |
---|---|
void |
beginResizing(int resizeCorner)
This method is called when resizing operation started.
|
protected javax.swing.event.MouseInputListener |
createMouseInputListener()
Creates the MouseInputListener for resizing.
|
void |
endResizing(int resizeCorner)
The method is called when resizing ends.
|
javax.swing.JComponent |
getComponent()
Gets the component which has this Resizable object.
|
javax.swing.event.MouseInputListener |
getMouseInputAdapter()
Gets the mouse adapter for resizing.
|
int |
getResizableCorners()
Gets the resizable corners.
|
int |
getResizeCornerSize()
Gets resize corner size.
|
java.awt.Insets |
getResizeInsets()
Returns the insets that should be used to calculate the resize area.
|
protected void |
installListeners()
Installs the listeners needed to perform resizing operations.
|
boolean |
isTopLevel()
Checks if the Resizable is added to a top level component.
|
void |
resizing(int resizeCorner,
int newX,
int newY,
int newW,
int newH)
This method is called during the resizing of ResizablePanel.
|
void |
setResizableCorners(int resizableCorners)
Sets resizable corners.
|
void |
setResizeCornerSize(int resizeCornerSize)
Sets the resize corner size.
|
void |
setResizeInsets(java.awt.Insets resizeInsets)
Sets the insets the be used to calculate the resize area.
|
void |
setTopLevel(boolean topLevel)
To indicates this
Resizable is installed on a top level component such as JWindow, JDialog and
JFrame v.s. |
void |
uninstallListeners()
Uninstalls the listeners that created to perform resizing operations.
|
public static final int NONE
public static final int UPPER_LEFT
public static final int UPPER
public static final int UPPER_RIGHT
public static final int RIGHT
public static final int LOWER_RIGHT
public static final int LOWER
public static final int LOWER_LEFT
public static final int LEFT
public static final int ALL
public static final java.lang.String PROPERTY_RESIZABLE_CORNERS
public static final java.lang.String PROPERTY_RESIZE_CORNER_SIZE
protected final javax.swing.JComponent _component
public Resizable(javax.swing.JComponent component)
Resizable
. This call will make the component to be resizable.public int getResizableCorners()
Resizable
.public void setResizableCorners(int resizableCorners)
resizableCorners
- new resizable corners. The value is a bitwise OR of eight constants defined in Resizable
.public int getResizeCornerSize()
public void setResizeCornerSize(int resizeCornerSize)
resizeCornerSize
- the resize corner size.protected void installListeners()
public void uninstallListeners()
protected javax.swing.event.MouseInputListener createMouseInputListener()
public javax.swing.event.MouseInputListener getMouseInputAdapter()
public void beginResizing(int resizeCorner)
resizeCorner
- the resize corner.public void resizing(int resizeCorner, int newX, int newY, int newW, int newH)
setPreferredSize(new Dimension(newW, newH));
getParent().doLayout();
in fact, depending on where you added this ResizablePanel, you may need to override this method to do something
else. For example, ResizableWindow
uses ResizablePanel
to implement resizable feature in
JWindow. It overrides this method to call setBounds on JWindow itself.resizeCorner
- the resize corner.newX
- the new x position.newY
- the new y position.newW
- the new width.newH
- the new height.public void endResizing(int resizeCorner)
resizeCorner
- the resize corner.public boolean isTopLevel()
If it's top level component, it will use screen coordinates to do all calculations during resizing. If resizing the resizable panel won't affect any top level container's position, you can return false here. Otherwise, return true. The default implementation always return false. Subclasses can override to return different value. In the case of ResizableWindow or ResizableDialog, this method is overridden and returns true.
public void setTopLevel(boolean topLevel)
Resizable
is installed on a top level component such as JWindow, JDialog and
JFrame v.s. a JPanel which is not a top level component because a JPanel must be added to another top level
component in order to be displayed.topLevel
- true or false.public javax.swing.JComponent getComponent()
public java.awt.Insets getResizeInsets()
public void setResizeInsets(java.awt.Insets resizeInsets)
resizeInsets
-