Class DraggableButton

  extended by de.matthiasmann.twl.Widget
      extended by de.matthiasmann.twl.TextWidget
          extended by de.matthiasmann.twl.Button
              extended by de.matthiasmann.twl.DraggableButton

public class DraggableButton
extends Button

A button which generates drag events. It's used in the ValueAdjuster and Scrollbar. This widget itself is mostly not usable, it's a building block for other components. This class is called DraggableButton, but it will not move itself when you start to drag on it, it fill forward the drag events to a listener which can then decide what to do with these.

See Also:

Nested Class Summary
static interface DraggableButton.DragListener
          The listener interface which receives all drag related events
Nested classes/interfaces inherited from class de.matthiasmann.twl.Widget
Widget.OffscreenMouseAdjustments, Widget.RenderOffscreen
Field Summary
Fields inherited from class de.matthiasmann.twl.Button
Fields inherited from class de.matthiasmann.twl.TextWidget
Fields inherited from class de.matthiasmann.twl.Widget
Constructor Summary
DraggableButton(AnimationState animState)
          Creates a DraggableButton with a shared animation state
DraggableButton(AnimationState animState, boolean inherit)
          Creates a DraggableButton with a shared or inherited animation state
Method Summary
 DraggableButton.DragListener getListener()
 boolean handleEvent(Event evt)
          Called when an event occurred that this widget could be interested in.
 boolean isDragActive()
 void setListener(DraggableButton.DragListener listener)
          Sets the DragListener.
Methods inherited from class de.matthiasmann.twl.Button
addCallback, afterAddToGUI, applyTheme, applyThemeButton, beforeRemoveFromGUI, disarm, doCallback, getMinHeight, getMinWidth, getModel, getMouseButton, getText, hasCallbacks, removeCallback, setEnabled, setModel, setMouseButton, setText, setVisible, widgetDisabled
Methods inherited from class de.matthiasmann.twl.TextWidget
applyThemeTextWidget, computeRelativeCursorPositionX, computeRelativeCursorPositionX, computeTextHeight, computeTextWidth, computeTextX, computeTextY, destroy, getAlignment, getCharSequence, getFont, getNumTextLines, getPreferredInnerHeight, getPreferredInnerWidth, handleMouseHover, hasText, isCache, isMultilineText, paintLabelText, paintTextAt, paintWidget, paintWithSelection, paintWithSelection, setAlignment, setCache, setCharSequence, setFont
Methods inherited from class de.matthiasmann.twl.Widget
add, addActionMapping, addPropertyChangeListener, addPropertyChangeListener, adjustSize, allChildrenRemoved, applyThemeBackground, applyThemeBorder, applyThemeInputMap, applyThemeMaxSize, applyThemeMinSize, applyThemeMouseCursor, applyThemeOffscreenExtra, applyThemeOverlay, applyThemeTooltip, borderChanged, canAcceptKeyboardFocus, childAdded, childInvalidateLayout, childRemoved, childVisibilityChanged, computeSize, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, focusFirstChild, focusLastChild, focusNextChild, focusPrevChild, getActionMap, getAnimationState, getBackground, getBorderBottom, getBorderHorizontal, getBorderLeft, getBorderRight, getBorderTop, getBorderVertical, getBottom, getChild, getChildAt, getChildIndex, getGUI, getHeight, getInnerBottom, getInnerHeight, getInnerRight, getInnerWidth, getInnerX, getInnerY, getInputMap, getKeyboardFocusOrder, getMaxHeight, getMaxWidth, getMouseCursor, getMouseCursor, getNumChildren, getOffscreenExtraBottom, getOffscreenExtraLeft, getOffscreenExtraRight, getOffscreenExtraTop, getOrCreateActionMap, getOverlay, getParent, getPreferredHeight, getPreferredWidth, getRenderOffscreen, getRight, getRootWidget, getTheme, getThemePath, getThemeTooltipContent, getTintAnimator, getTooltipContent, getTooltipContentAt, getWidgetAt, getWidth, getX, getY, giveupKeyboardFocus, handleKeyStrokeAction, hasKeyboardFocus, hasOpenPopups, hasSharedAnimationState, insertChild, invalidateLayout, invalidateLayoutLocally, isAbsoluteTheme, isClip, isDepthFocusTraversal, isEnabled, isFocusKeyEnabled, isInside, isLocallyEnabled, isMouseInside, isVisible, keyboardFocusChildChanged, keyboardFocusGained, keyboardFocusGained, keyboardFocusLost, layout, layoutChildFullInnerArea, layoutChildrenFullInnerArea, moveChild, paint, paintBackground, paintChild, paintChildren, paintDragOverlay, paintOverlay, positionChanged, reapplyTheme, removeAllChildren, removeChild, removeChild, removePropertyChangeListener, removePropertyChangeListener, requestKeyboardFocus, requestKeyboardFocus, resetTooltip, setActionMap, setBackground, setBorderSize, setBorderSize, setBorderSize, setBorderSize, setCanAcceptKeyboardFocus, setClip, setDepthFocusTraversal, setFocusKeyEnabled, setInnerSize, setInputMap, setMaxSize, setMinSize, setMouseCursor, setOffscreenExtra, setOffscreenExtra, setOverlay, setPosition, setRenderOffscreen, setSize, setTheme, setTintAnimator, setTooltipContent, sizeChanged, updateTintAnimation, updateTooltip, validateLayout
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public DraggableButton()


public DraggableButton(AnimationState animState)
Creates a DraggableButton with a shared animation state

animState - the animation state to share, can be null


public DraggableButton(AnimationState animState,
                       boolean inherit)
Creates a DraggableButton with a shared or inherited animation state

animState - the animation state to share or inherit, can be null
inherit - true if the animation state should be inherited false for sharing
Method Detail


public boolean isDragActive()


public DraggableButton.DragListener getListener()


public void setListener(DraggableButton.DragListener listener)
Sets the DragListener. Only one listener can be set. Setting a new one will replace the previous one. Changing the listener while a drag is active will result in incomplete events for both listeners (previous and new one).

listener - the new listener or null


public boolean handleEvent(Event evt)
Description copied from class: Widget
Called when an event occurred that this widget could be interested in.

The default implementation handles only keyboard events and delegates them to the child widget which has keyboard focus. If focusKey handling is enabled then this widget cycles the keyboard focus through it's children. If the key was not consumed by a child or focusKey and an inputMap is specified then the event is translated by the InputMap and handleKeyStrokeAction is called when a mapping was found.

If the widget wants to receive mouse events then it must return true for all mouse events except for MOUSE_WHEEL (which is optional) event. Otherwise the following mouse event are not send. Before mouse movement or button events are send a MOUSE_ENTERED event is send first.

handleEvent in class Button
evt - The event - do not store this object - it may be reused
true if the widget handled this event
See Also:
Widget.setFocusKeyEnabled(boolean), Widget.handleKeyStrokeAction(java.lang.String, de.matthiasmann.twl.Event), Widget.setInputMap(de.matthiasmann.twl.InputMap)