Swing ExtrasThe following classes are Swing utilities classes. Classes
| LicenseThis software is released under the GNU GPLv3 license
| DownloadDownload the Swing extras package
| VariableGridLayoutThe VariableGridLayout class is a very similar to the the java.awt.GridLayoutClass in that it positions component in a grid layout (ie rows and columns). This makes it very easy to use when laying out a grid of components such as for forms.This class is used in the DateSelector GUI to layout the day buttons, week numbers and day names.
| SelectableLineBorderThe SelectableLineBorder class is similar to the javax.swing.border.LineBorder class in that it draws a line border of the specified width and colour around the given component. However, with the SelectableLineBorder you can specify which sides to draw the line on. So, for example you can underline components, draw lines above and below components etcThis class is used in the DateSelector GUI to draw vertical lines either side of the week numbers and horizontal lines above and below the day names. For example to draw lines above and below a component use:
|
| To draw a double line above and a single line below a component use:
|
|
| HoverDetectorThe HoverDetector class monitors a component to detect if the mouse is hovering over it and, if a hover is detected, the callable object is sent a notification.When a HoverDetector is created it receives the component to monitor, a callable object to notify and optionally a time to wait for a hover in milliseconds. The callable object is called when a hover is detected so it can handle the hover action. If the hover action results in a Window being displayed, returning a reference to the Window via the callable's return value will allow the Hover Detector to automatically close the window if it loses focus. This class is used in the DateSelectorTest GUI to popup a DateSelector panel if the mouse hovers over the label and to remove the popup if it loses focus.
|
| GesturesA gesture is a predefined movement of the mouse to signal a specific action is to be undertaken. For example a list of items could be sorted into descending order by dragging the mouse vertically downwards on the list, into ascending order by dragging the mouse vertically upwards or shuffled by an up down motion.The Gesture class monitors a component to detect when a gesture occurs. A gesture is deemed to occur when the left mouse button is pressed and the mouse is dragged a given distance in a direction or combination of directions. The class supports two separate notification mechanisms:
Gestures are particularly useful for touch screen systems as there isn't a choice of mouse buttons, scroll wheels etc to prompt different actions. They are also useful as mouse shortcuts for example: actions that are regularly run by selecting a menu item from a popup menu could be assigned a gesture, then a quick movement could be used instead of having to use a right mouse click, a mouse movement to hover over the menu item and then a left click on the menu item. Using the Gesture class is as simple as adding the components to be monitored and setting up the notification mechanism, either by adding listeners and handling the action yourself or mapping a gesture through to an Action object which is run in response to the mapped gesture. For example: Using Listener Notification:
|
| Using Action Objects:
|
| The distance, in pixels, the mouse has to travel for the movement to be registered as a gesture can be configured by calling the setMinMovement(..) method.
|
| |