Package org.apache.pivot.wtk
Class Component
- java.lang.Object
-
- org.apache.pivot.wtk.Component
-
- All Implemented Interfaces:
ConstrainedVisual,Visual
- Direct Known Subclasses:
ActivityIndicator,Button,ChartView,Container,Gauge,GridPane.Filler,ImageView,Label,ListView,Meter,MovieView,NumberRuler,Ruler,ScrollPane.Corner,Separator,TablePane.Filler,TableView,TableViewHeader,TerraRollupSkin.RollupButton,TerraScrollBarSkin.Handle,TerraScrollBarSkin.ScrollButton,TerraSliderSkin.Thumb,TerraSpinnerSkin.SpinButton,TerraSpinnerSkin.SpinnerContent,TerraSplitPaneSkin.Splitter,TerraSplitPaneSkin.SplitterShadow,TextArea,TextInput,TreeView
@IDProperty("name") public abstract class Component extends java.lang.Object implements ConstrainedVisual
Top level abstract base class for all components. In MVC terminology, a component represents the "controller". It has no inherent visual representation and acts as an intermediary between the component's data (the "model") and the skin, an implementation ofSkinwhich serves as the "view".
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classComponent.DecoratorSequenceDecorator sequence implementation.classComponent.StyleDictionaryStyle dictionary implementation.classComponent.UserDataDictionaryUser data dictionary implementation.
-
Constructor Summary
Constructors Constructor Description Component()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckSkin(Skin skin, java.lang.Class<?> expectedClass)Check if the given skin is correct with respect to the necessary skin class.voidclear()Clears any bound values in the component.static voidclearFocus()Clears the focus.booleancontains(int xValue, int yValue)Determines if the component contains a given location.voidcopyStyle(java.lang.String style, Component comp)Copy the given style from the other component to this one.voidcopyStyle(Style style, Component comp)Copy the given style from the other component to this one.ContainergetAncestor(java.lang.Class<? extends Container> ancestorType)ContainergetAncestor(java.lang.String ancestorTypeName)<T extends java.lang.Enum<T>>
java.lang.ObjectgetAttribute(T key)Gets the specified component attribute.java.lang.StringgetAutomationID()Returns the component's automation ID.intgetBaseline()Returns the component's baseline.intgetBaseline(int width, int height)Returns the component's baseline for a given width and height.BoundsgetBounds()static ListenerList<ComponentClassListener>getComponentClassListeners()ListenerList<ComponentDataListener>getComponentDataListeners()ListenerList<ComponentDecoratorListener>getComponentDecoratorListeners()ListenerList<ComponentKeyListener>getComponentKeyListeners()ListenerList<ComponentListener>getComponentListeners()ListenerList<ComponentMouseButtonListener>getComponentMouseButtonListeners()ListenerList<ComponentMouseListener>getComponentMouseListeners()ListenerList<ComponentMouseWheelListener>getComponentMouseWheelListeners()ListenerList<ComponentStateListener>getComponentStateListeners()ListenerList<ComponentStyleListener>getComponentStyleListeners()ListenerList<ComponentTooltipListener>getComponentTooltipListeners()CursorgetCursor()Returns the cursor that is displayed when the mouse pointer is over this component.BoundsgetDecoratedBounds()Component.DecoratorSequencegetDecorators()DisplaygetDisplay()DragSourcegetDragSource()DropTargetgetDropTarget()static ComponentgetFocusedComponent()Returns the currently focused component.java.awt.Graphics2DgetGraphics()Creates a graphics context for this component.intgetHeight()Returns the visual's height.LimitsgetHeightLimits()PointgetLocation()intgetMaximumHeight()intgetMaximumWidth()MenuHandlergetMenuHandler()intgetMinimumHeight()intgetMinimumWidth()PointgetMouseLocation()Returns the current mouse location in the component's coordinate space.java.lang.StringgetName()static Map<java.lang.String,Map<java.lang.String,?>>getNamedStyles()ContainergetParent()intgetPreferredHeight()intgetPreferredHeight(int width)Returns the component's constrained preferred height.DimensionsgetPreferredSize()Returns the visual's unconstrained preferred size.intgetPreferredWidth()intgetPreferredWidth(int height)Returns the component's constrained preferred width.BoundsgetScreenBounds()Returns the component's bounding area in screen coordinates.DimensionsgetSize()Default method to return the visual's complete size via aDimensionsobject.protected SkingetSkin()Returns the currently installed skin.java.lang.ObjectgetStyle(java.lang.String style)Get the style value corresponding to the given style key.java.lang.ObjectgetStyle(Style style)Get the style value corresponding to the given style key.booleangetStyleBoolean(java.lang.String style)Get the boolean value corresponding to the given style key.booleangetStyleBoolean(Style style)Get the boolean value corresponding to the given style key.java.awt.ColorgetStyleColor(java.lang.String style)Get the color value corresponding to the given style key.java.awt.ColorgetStyleColor(Style style)Get the color value corresponding to the given style key.java.awt.FontgetStyleFont(java.lang.String style)Get the font value corresponding to the given style key.java.awt.FontgetStyleFont(Style style)Get the font value corresponding to the given style key.intgetStyleInt(java.lang.String style)Get the integer value corresponding to the given style key.intgetStyleInt(Style style)Get the integer value corresponding to the given style key.Component.StyleDictionarygetStyles()TextInputMethodListenergetTextInputMethodListener()Returns the input method listener for this component, which will reside in the skin, so defer to the skin class.intgetTooltipDelay()java.lang.StringgetTooltipText()booleangetTooltipWrapText()Returns the tooltip's mode for wrapping its text.static Map<java.lang.Class<? extends Component>,Map<java.lang.String,?>>getTypedStyles()Component.UserDataDictionarygetUserData()BoundsgetVisibleArea()Determines the visible area of a component.BoundsgetVisibleArea(int xValue, int yValue, int width, int height)Determines the visible area of the given rectangle.BoundsgetVisibleArea(Bounds area)Determines the visible portion of a given area.intgetWidth()Returns the visual's width.LimitsgetWidthLimits()WindowgetWindow()intgetX()intgetY()protected static voidindexBoundsCheck(java.lang.String indexName, int index, int min, int max)Check an index value against the provided bounds and throw a nicely formatted exception, including the index name, for out of range values.protected voidinstallSkin(java.lang.Class<? extends Component> componentClass)Installs the skin for the given component class, as defined by the current theme.voidinvalidate()Flags the component's hierarchy as invalid, and clears any cached preferred size.booleanisBlocked()Determines if this component is blocked.booleanisEnabled()Returns the component's enabled state.booleanisFocusable()Returns this component's focusability.booleanisFocused()Returns the component's focused state.booleanisMouseOver()Determines if the mouse is positioned over this component.booleanisOpaque()Tells whether or not this component is fully opaque when painted.booleanisPreferredHeightSet()Returns a flag indicating whether the preferred height was explicitly set by the caller or is the default value determined by the skin.booleanisPreferredSizeSet()Returns a flag indicating whether the preferred size was explicitly set by the caller or is the default value determined by the skin.booleanisPreferredWidthSet()Returns a flag indicating whether the preferred width was explicitly set by the caller or is the default value determined by the skin.booleanisShowing()Determines if this component is showing.booleanisValid()booleanisVisible()Returns the component's visibility.protected booleankeyPressed(int keyCode, Keyboard.KeyLocation keyLocation)protected booleankeyReleased(int keyCode, Keyboard.KeyLocation keyLocation)protected booleankeyTyped(char character)protected voidlayout()Called to lay out the component.voidload(java.lang.Object context)Copies bound values from the bind context to the component.PointmapPointFromAncestor(Container ancestor, int xValue, int yValue)Maps a point in the specified ancestor's coordinate space to this component's coordinate system.PointmapPointFromAncestor(Container ancestor, Point location)PointmapPointToAncestor(Container ancestor, int xValue, int yValue)Maps a point in this component's coordinate system to the specified ancestor's coordinate space.PointmapPointToAncestor(Container ancestor, Point location)Maps a point in this component's coordinate system to the specified ancestor's coordinate space.protected booleanmouseClick(Mouse.Button button, int xValue, int yValue, int count)protected booleanmouseDown(Mouse.Button button, int xValue, int yValue)protected booleanmouseMove(int xValue, int yValue)protected voidmouseOut()protected voidmouseOver()protected booleanmouseUp(Mouse.Button button, int xValue, int yValue)protected booleanmouseWheel(Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int xValue, int yValue)java.awt.RectangleoffsetToScreen(java.awt.Rectangle clientRectangle)Convert and return a newRectanglefrom component-relative coordinates to screen-relative.voidpaint(java.awt.Graphics2D graphics)Paints the component.voidputStyle(java.lang.String style, java.lang.Object value)Put the given key/value style into the style dictionary.voidputStyle(Style style, java.lang.Object value)Put the given key/value style into the style dictionary.voidreenterMouse()If the mouse is currently over the component, causes the component to firemouseOut()and amouseMove()at the current mouse location.voidrepaint()Flags the entire component as needing to be repainted.voidrepaint(boolean immediate)Flags the entire component as needing to be repainted.voidrepaint(int xValue, int yValue, int width, int height)Flags an area as needing to be repainted.voidrepaint(int xValue, int yValue, int width, int height, boolean immediate)Flags an area as needing to be repainted.voidrepaint(Bounds area)Flags an area as needing to be repainted.voidrepaint(Bounds area, boolean immediate)Flags an area as needing to be repainted or repaints the rectangle immediately.booleanrequestFocus()Requests that focus be given to this component.voidscrollAreaToVisible(int xValue, int yValue, int width, int height)Ensures that the given area of a component is visible within the viewports of all applicable ancestors.voidscrollAreaToVisible(Bounds area)Ensures that the given area of a component is visible within the viewports of all applicable ancestors.<T extends java.lang.Enum<T>>
java.lang.ObjectsetAttribute(T key, java.lang.Object value)Sets the specified component attribute.<E extends java.lang.Enum<E>>
voidsetAutomationID(E enumID)Set the automation ID via an enum value.voidsetAutomationID(java.lang.String automationID)Sets the component's automation ID.voidsetCursor(Cursor cursor)Sets the cursor that is displayed when the mouse pointer is over this component.voidsetDragSource(DragSource dragSource)voidsetDropTarget(DropTarget dropTarget)voidsetEnabled(boolean enabled)Sets the component's enabled state.protected voidsetFocused(boolean focused, Component obverseComponent)Called to notify a component that its focus state has changed.voidsetHeight(int height)voidsetHeightLimits(int minimumHeight, int maximumHeight)Sets the height limits for this component.voidsetHeightLimits(Limits heightLimits)Sets the height limits for this component.voidsetLocation(int x, int y)Sets the component's location.voidsetLocation(Point location)Sets the component's location.voidsetMaximumHeight(int maximumHeight)Sets the maximum height of this component.voidsetMaximumWidth(int maximumWidth)Sets the maximum width of this component.voidsetMenuHandler(MenuHandler menuHandler)voidsetMinimumHeight(int minimumHeight)Sets the minimum height of this component.voidsetMinimumWidth(int minimumWidth)Sets the minimum width of this component.voidsetName(java.lang.String name)Sets the component's name.protected voidsetParent(Container parent)voidsetPreferredHeight(int preferredHeight)Sets the component's preferred height.voidsetPreferredSize(int preferredWidth, int preferredHeight)Sets the component's preferred size.voidsetPreferredSize(Dimensions preferredSize)voidsetPreferredWidth(int preferredWidth)Sets the component's preferred width.voidsetSize(int width, int height)NOTE This method should only be called during layout.voidsetSize(Dimensions size)Default method to set the visual size via aDimensionsvalue.protected voidsetSkin(Skin skin)Sets the skin, replacing any previous skin.voidsetStyleName(java.lang.String styleName)Applies a named style to this component.voidsetStyleNames(java.lang.String styleNames)Applies a set of named styles.voidsetStyleNames(Sequence<java.lang.String> styleNames)Applies a set of named styles.voidsetStyles(java.lang.String styles)Applies a set of styles.voidsetStyles(Map<java.lang.String,?> styles)Applies a set of styles.voidsetTooltipDelay(int tooltipDelay)Sets the component's tooltip delay.voidsetTooltipText(java.lang.String tooltipText)Sets the component's tooltip text.voidsetTooltipWrapText(boolean tooltipWrapText)Sets the tooltip's text wrapping mode.voidsetVisible(boolean visible)Sets the component's visibility.voidsetWidth(int width)voidsetWidthLimits(int minimumWidth, int maximumWidth)Sets the width limits for this component.voidsetWidthLimits(Limits widthLimits)Sets the width limits for this component.voidsetX(int x)Sets the component's x-coordinate.voidsetY(int y)Sets the component's y-coordinate.voidstore(java.lang.Object context)Copies bound values from the component to the bind context.java.lang.StringtoString()ComponenttransferFocus(FocusTraversalDirection direction)Transfers focus to the next focusable component in the given direction.voidvalidate()Lays out the component by callingSkin.layout().
-
-
-
Method Detail
-
getAutomationID
public java.lang.String getAutomationID()
Returns the component's automation ID.- Returns:
- The component's automation ID, or
nullif the component does not have an automation ID.
-
setAutomationID
public void setAutomationID(java.lang.String automationID)
Sets the component's automation ID. This value can be used to obtain a reference to the component viaAutomation.get(String)when the component is attached to a component hierarchy.- Parameters:
automationID- The automation ID to use for the component, ornullto clear the automation ID.
-
setAutomationID
public <E extends java.lang.Enum<E>> void setAutomationID(E enumID)
Set the automation ID via an enum value.- Type Parameters:
E- The enum type that will be used here.- Parameters:
enumID- The enum value to use as the automation ID for this component, ornullto clear the automation ID.- See Also:
setAutomationID(String)
-
getSkin
protected Skin getSkin()
Returns the currently installed skin.- Returns:
- The currently installed skin.
-
setSkin
protected void setSkin(Skin skin)
Sets the skin, replacing any previous skin.- Parameters:
skin- The new skin.
-
checkSkin
protected final void checkSkin(Skin skin, java.lang.Class<?> expectedClass)
Check if the given skin is correct with respect to the necessary skin class.Meant to be called from the subclass'
setSkin(org.apache.pivot.wtk.Skin)method.- Parameters:
skin- The skin object to check.expectedClass- What the skin class should be.- Throws:
java.lang.IllegalArgumentException- if the skin object doesn't implement the given skin interface.
-
installSkin
protected void installSkin(java.lang.Class<? extends Component> componentClass)
Installs the skin for the given component class, as defined by the current theme.- Parameters:
componentClass- Pivot component class for which to install the skin.
-
getParent
public Container getParent()
-
setParent
protected void setParent(Container parent)
-
getWindow
public Window getWindow()
-
getDisplay
public Display getDisplay()
-
getAncestor
public Container getAncestor(java.lang.String ancestorTypeName) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
getWidth
public int getWidth()
Description copied from interface:VisualReturns the visual's width.
-
setWidth
public void setWidth(int width)
-
getHeight
public int getHeight()
Description copied from interface:VisualReturns the visual's height.
-
setHeight
public void setHeight(int height)
-
getSize
public Dimensions getSize()
Description copied from interface:VisualDefault method to return the visual's complete size via aDimensionsobject. Note that if the width and height calculations for a particular object are lengthy and could be better done together rather than separately, that component should be free to override this default implementation.
-
setSize
public final void setSize(Dimensions size)
Description copied from interface:ConstrainedVisualDefault method to set the visual size via aDimensionsvalue.- Specified by:
setSizein interfaceConstrainedVisual- Parameters:
size- The complete size of this visual.
-
setSize
public void setSize(int width, int height)NOTE This method should only be called during layout. Callers should usesetPreferredSize(int, int).- Specified by:
setSizein interfaceConstrainedVisual- Parameters:
width- Final computed widthheight- Final computed height
-
getPreferredWidth
public int getPreferredWidth()
- Returns:
- The component's unconstrained preferred width.
-
getPreferredWidth
public int getPreferredWidth(int height)
Returns the component's constrained preferred width.- Specified by:
getPreferredWidthin interfaceConstrainedVisual- Parameters:
height- The height value by which the preferred width should be constrained, or-1for no constraint.- Returns:
- The constrained preferred width.
-
setPreferredWidth
public void setPreferredWidth(int preferredWidth)
Sets the component's preferred width.- Parameters:
preferredWidth- The preferred width value, or-1to use the default value determined by the skin.
-
isPreferredWidthSet
public boolean isPreferredWidthSet()
Returns a flag indicating whether the preferred width was explicitly set by the caller or is the default value determined by the skin.- Returns:
trueif the preferred width was explicitly set;false, otherwise.
-
getPreferredHeight
public int getPreferredHeight()
- Returns:
- The component's unconstrained preferred height.
-
getPreferredHeight
public int getPreferredHeight(int width)
Returns the component's constrained preferred height.- Specified by:
getPreferredHeightin interfaceConstrainedVisual- Parameters:
width- The width value by which the preferred height should be constrained, or-1for no constraint.- Returns:
- The constrained preferred height.
-
setPreferredHeight
public void setPreferredHeight(int preferredHeight)
Sets the component's preferred height.- Parameters:
preferredHeight- The preferred height value, or-1to use the default value determined by the skin.
-
isPreferredHeightSet
public boolean isPreferredHeightSet()
Returns a flag indicating whether the preferred height was explicitly set by the caller or is the default value determined by the skin.- Returns:
trueif the preferred height was explicitly set;false, otherwise.
-
getPreferredSize
public Dimensions getPreferredSize()
Description copied from interface:ConstrainedVisualReturns the visual's unconstrained preferred size.- Specified by:
getPreferredSizein interfaceConstrainedVisual- Returns:
- The component's unconstrained preferred size.
-
setPreferredSize
public final void setPreferredSize(Dimensions preferredSize)
-
setPreferredSize
public void setPreferredSize(int preferredWidth, int preferredHeight)Sets the component's preferred size.- Parameters:
preferredWidth- The preferred width value, or-1to use the default value determined by the skin.preferredHeight- The preferred height value, or-1to use the default value determined by the skin.
-
isPreferredSizeSet
public boolean isPreferredSizeSet()
Returns a flag indicating whether the preferred size was explicitly set by the caller or is the default value determined by the skin.- Returns:
trueif the preferred size was explicitly set;false, otherwise.
-
getMinimumWidth
public int getMinimumWidth()
- Returns:
- The given minimum width of this component.
-
setMinimumWidth
public void setMinimumWidth(int minimumWidth)
Sets the minimum width of this component.- Parameters:
minimumWidth- The new minimum width for this component.
-
getMaximumWidth
public int getMaximumWidth()
- Returns:
- The given maximum width of this component.
-
setMaximumWidth
public void setMaximumWidth(int maximumWidth)
Sets the maximum width of this component.- Parameters:
maximumWidth- The new maximum width of this component.
-
getWidthLimits
public Limits getWidthLimits()
- Returns:
- The current width limits (min and max) for this component.
-
setWidthLimits
public void setWidthLimits(int minimumWidth, int maximumWidth)Sets the width limits for this component.- Parameters:
minimumWidth- The new minimum width.maximumWidth- The new maximum width.
-
setWidthLimits
public final void setWidthLimits(Limits widthLimits)
Sets the width limits for this component.- Parameters:
widthLimits- The new width limits (min and max).
-
getMinimumHeight
public int getMinimumHeight()
- Returns:
- The given minimum height of this component.
-
setMinimumHeight
public void setMinimumHeight(int minimumHeight)
Sets the minimum height of this component.- Parameters:
minimumHeight- The new minimum height.
-
getMaximumHeight
public int getMaximumHeight()
- Returns:
- The given maximum height of this component.
-
setMaximumHeight
public void setMaximumHeight(int maximumHeight)
Sets the maximum height of this component.- Parameters:
maximumHeight- The new maximum height.
-
getHeightLimits
public Limits getHeightLimits()
- Returns:
- The current height limits (min and max) for this component.
-
setHeightLimits
public void setHeightLimits(int minimumHeight, int maximumHeight)Sets the height limits for this component.- Parameters:
minimumHeight- The new minimum height.maximumHeight- The new maximum height.
-
setHeightLimits
public final void setHeightLimits(Limits heightLimits)
Sets the height limits for this component.- Parameters:
heightLimits- The new height limits (min and max).
-
getX
public int getX()
- Returns:
- The component's x-coordinate or its horizontal position relative to the origin of the parent container.
-
setX
public void setX(int x)
Sets the component's x-coordinate.- Parameters:
x- The component's horizontal position relative to the origin of the parent container.
-
getY
public int getY()
- Returns:
- The component's y-coordinate or its vertical position relative to the origin of the parent container.
-
setY
public void setY(int y)
Sets the component's y-coordinate.- Parameters:
y- The component's vertical position relative to the origin of the parent container.
-
getLocation
public Point getLocation()
- Returns:
- A point value containing the component's location or its horizontal and vertical position relative to the origin of the parent container.
-
setLocation
public void setLocation(int x, int y)Sets the component's location. NOTE This method should only be called when performing layout. However, since some containers do not reposition components during layout, it is valid for callers to invoke this method directly for such containers.- Parameters:
x- The component's horizontal position relative to the origin of the parent container.y- The component's vertical position relative to the origin of the parent container.
-
setLocation
public final void setLocation(Point location)
Sets the component's location.- Parameters:
location- A point value containing the component's horizontal and vertical position relative to the origin of the parent container.- See Also:
setLocation(int, int)
-
getBaseline
public int getBaseline()
Returns the component's baseline.- Specified by:
getBaselinein interfaceVisual- Returns:
- The baseline relative to the origin of this component, or
-1if this component does not have a baseline.
-
getBaseline
public int getBaseline(int width, int height)Returns the component's baseline for a given width and height.- Specified by:
getBaselinein interfaceConstrainedVisual- Parameters:
width- Constrained width to compute the baseline for.height- Constrained height to compute the baseline for.- Returns:
- The baseline relative to the origin of this component, or
-1if this component does not have a baseline.
-
getBounds
public Bounds getBounds()
- Returns:
- The component's bounding area. The
xandyvalues are relative to the parent container.
-
getDecoratedBounds
public Bounds getDecoratedBounds()
- Returns:
- The component's bounding area including decorators.
The
xandyvalues are relative to the parent container.
-
getScreenBounds
public Bounds getScreenBounds()
Returns the component's bounding area in screen coordinates.The result is the result of
getBounds()offset by all the parent containers of this component, and offset by the application'sDisplayon the screen.- Returns:
- The component's bounding area relative to the entire screen.
-
offsetToScreen
public java.awt.Rectangle offsetToScreen(java.awt.Rectangle clientRectangle)
Convert and return a newRectanglefrom component-relative coordinates to screen-relative. Uses thegetScreenBounds()method to accomplish the mapping.- Parameters:
clientRectangle- A rectangle in component-relative coordinates.- Returns:
- A new object in screen-relative coordinates.
-
contains
@UnsupportedOperation public boolean contains(int xValue, int yValue)
Determines if the component contains a given location. This method facilitates mouse interaction with non-rectangular components.- Parameters:
xValue- Horizontal location to check.yValue- Vertical location to check.- Returns:
trueif the component's shape contains the given location;false, otherwise.- Throws:
java.lang.UnsupportedOperationException- This method is not currently implemented.
-
isVisible
public boolean isVisible()
Returns the component's visibility.- Returns:
trueif the component will be painted;false, otherwise.
-
setVisible
public void setVisible(boolean visible)
Sets the component's visibility.- Parameters:
visible-trueif the component should be painted;false, otherwise.
-
getDecorators
public Component.DecoratorSequence getDecorators()
- Returns:
- The component's decorator sequence
-
mapPointToAncestor
public Point mapPointToAncestor(Container ancestor, int xValue, int yValue)
Maps a point in this component's coordinate system to the specified ancestor's coordinate space.- Parameters:
ancestor- The ancestor container of this component.xValue- The x-coordinate in this component's coordinate space.yValue- The y-coordinate in this component's coordinate space.- Returns:
- A point containing the translated coordinates, or
nullif the component is not a descendant of the specified ancestor.
-
mapPointToAncestor
public Point mapPointToAncestor(Container ancestor, Point location)
Maps a point in this component's coordinate system to the specified ancestor's coordinate space.- Parameters:
ancestor- The ancestor container of this component.location- The coordinates in this component's coordinate space.- Returns:
- A point containing the translated coordinates, or
nullif the component is not a descendant of the specified ancestor.
-
mapPointFromAncestor
public Point mapPointFromAncestor(Container ancestor, int xValue, int yValue)
Maps a point in the specified ancestor's coordinate space to this component's coordinate system.- Parameters:
ancestor- The ancestor container of this component.xValue- The x-coordinate in the ancestors's coordinate space.yValue- The y-coordinate in the ancestor's coordinate space.- Returns:
- A point containing the translated coordinates, or
nullif the component is not a descendant of the specified ancestor.
-
isShowing
public boolean isShowing()
Determines if this component is showing. To be showing, the component and all of its ancestors must be visible and attached to a display.- Returns:
trueif this component is showing;falseotherwise.
-
getVisibleArea
public Bounds getVisibleArea()
Determines the visible area of a component. The visible area is defined as the intersection of the component's area with the visible area of its ancestors, or, in the case of a Viewport, the viewport bounds.- Returns:
- The visible area of the component in the component's coordinate
space, or
nullif the component is either not showing or not part of the component hierarchy.
-
getVisibleArea
public Bounds getVisibleArea(Bounds area)
Determines the visible portion of a given area. The visible area is defined as the intersection of the component's area with the visible area of its ancestors, or, in the case of a Viewport, the viewport bounds.- Parameters:
area- The area to check its visibility.- Returns:
- The visible part of the given area in the component's coordinate
space, or
nullif the component is either not showing or not part of the component hierarchy.
-
getVisibleArea
public Bounds getVisibleArea(int xValue, int yValue, int width, int height)
Determines the visible area of the given rectangle. The visible area is defined as the intersection of the component's area with the visible area of its ancestors, or, in the case of a Viewport, the viewport bounds.- Parameters:
xValue- The x-coordinate of the area.yValue- The y-coordinate of the area.width- The width of the area.height- The height of the area.- Returns:
- The visible part of the given area in the component's coordinate
space, or
nullif the component is either not showing or not part of the component hierarchy.
-
scrollAreaToVisible
public void scrollAreaToVisible(Bounds area)
Ensures that the given area of a component is visible within the viewports of all applicable ancestors.- Parameters:
area- The area to be made visible.
-
scrollAreaToVisible
public void scrollAreaToVisible(int xValue, int yValue, int width, int height)Ensures that the given area of a component is visible within the viewports of all applicable ancestors.- Parameters:
xValue- The x-coordinate of the area to be made visible.yValue- The y-coordinate of the area.width- The width of the area to be shown.height- The height of the area.
-
isValid
public boolean isValid()
- Returns:
- Whether or not the component is valid.
-
invalidate
public void invalidate()
Flags the component's hierarchy as invalid, and clears any cached preferred size.
-
validate
public void validate()
Lays out the component by callingSkin.layout().
-
layout
protected void layout()
Called to lay out the component.
-
repaint
public final void repaint()
Flags the entire component as needing to be repainted.
-
repaint
public final void repaint(boolean immediate)
Flags the entire component as needing to be repainted.- Parameters:
immediate- Whether to repaint immediately.
-
repaint
public final void repaint(Bounds area)
Flags an area as needing to be repainted.- Parameters:
area- The area that needs to be repainted.
-
repaint
public final void repaint(Bounds area, boolean immediate)
Flags an area as needing to be repainted or repaints the rectangle immediately.- Parameters:
area- The area to be repainted.immediate- Whether or not the area needs immediate painting.
-
repaint
public final void repaint(int xValue, int yValue, int width, int height)Flags an area as needing to be repainted.- Parameters:
xValue- Starting x-coordinate of area to paint.yValue- Starting y-coordinate.width- Width of area to repaint.height- Height of the area.
-
repaint
public void repaint(int xValue, int yValue, int width, int height, boolean immediate)Flags an area as needing to be repainted.- Parameters:
xValue- Starting x-coordinate of area to repaint.yValue- Starting y-coordinate.width- Width of area to repaint.height- Height of area.immediate- Whether repaint should be done immediately.
-
paint
public void paint(java.awt.Graphics2D graphics)
Paints the component. Delegates to the skin.
-
getGraphics
public java.awt.Graphics2D getGraphics()
Creates a graphics context for this component. This graphics context will not be double buffered. In other words, drawing operations on it will operate directly on the video RAM.- Returns:
- A graphics context for this component, or
nullif this component is not showing. - See Also:
isShowing()
-
isEnabled
public boolean isEnabled()
Returns the component's enabled state.- Returns:
trueif the component is enabled;false, otherwise.
-
setEnabled
public void setEnabled(boolean enabled)
Sets the component's enabled state. Enabled components respond to user input events; disabled components do not.- Parameters:
enabled-trueif the component is enabled;false, otherwise.
-
isBlocked
public boolean isBlocked()
Determines if this component is blocked. A component is blocked if the component or any of its ancestors is disabled.- Returns:
trueif the component is blocked;false, otherwise.
-
isMouseOver
public boolean isMouseOver()
Determines if the mouse is positioned over this component.- Returns:
trueif the mouse is currently located over this component;false, otherwise.
-
getMouseLocation
public Point getMouseLocation()
Returns the current mouse location in the component's coordinate space.- Returns:
- The current mouse location, or
nullif the mouse is not currently positioned over this component.
-
getCursor
public Cursor getCursor()
Returns the cursor that is displayed when the mouse pointer is over this component.- Returns:
- The cursor that is displayed over the component.
-
setCursor
public void setCursor(Cursor cursor)
Sets the cursor that is displayed when the mouse pointer is over this component.- Parameters:
cursor- The cursor to display over the component, ornullto inherit the cursor of the parent container.
-
getTooltipText
public java.lang.String getTooltipText()
- Returns:
- The component's tooltip text, or
nullif no tooltip is specified.
-
setTooltipText
public void setTooltipText(java.lang.String tooltipText)
Sets the component's tooltip text.- Parameters:
tooltipText- The component's tooltip text, ornullfor no tooltip.
-
getTooltipDelay
public int getTooltipDelay()
- Returns:
- The component's tooltip delay, in milliseconds.
-
setTooltipDelay
public void setTooltipDelay(int tooltipDelay)
Sets the component's tooltip delay.- Parameters:
tooltipDelay- The tooltip delay, in milliseconds.
-
getTooltipWrapText
public boolean getTooltipWrapText()
Returns the tooltip's mode for wrapping its text.- Returns:
trueif the tooltip text wrap mode is enabled;falseif not.
-
setTooltipWrapText
public void setTooltipWrapText(boolean tooltipWrapText)
Sets the tooltip's text wrapping mode.- Parameters:
tooltipWrapText- The component's tooltip text wrap mode.
-
isOpaque
public boolean isOpaque()
Tells whether or not this component is fully opaque when painted.- Returns:
trueif this component is opaque;falseif any part of it is transparent or translucent.
-
isFocusable
public boolean isFocusable()
Returns this component's focusability. A focusable component is capable of receiving the focus only when it is showing, unblocked, and its window is not closing.- Returns:
trueif the component is capable of receiving the focus;false, otherwise.
-
isFocused
public boolean isFocused()
Returns the component's focused state.- Returns:
trueif the component has the input focus;falseotherwise.
-
setFocused
protected void setFocused(boolean focused, Component obverseComponent)Called to notify a component that its focus state has changed.- Parameters:
focused-trueif the component has received the input focus;falseif the component has lost the focus.obverseComponent- Iffocusedis true, the component that has lost the focus; otherwise, the component that has gained the focus.
-
requestFocus
public boolean requestFocus()
Requests that focus be given to this component.- Returns:
trueif the component gained the focus;falseotherwise.
-
transferFocus
public Component transferFocus(FocusTraversalDirection direction)
Transfers focus to the next focusable component in the given direction.- Parameters:
direction- The direction in which to transfer focus.- Returns:
- The new component that has received the focus or
nullif no component is focused.
-
getFocusedComponent
public static Component getFocusedComponent()
Returns the currently focused component.- Returns:
- The component that currently has the focus, or
nullif no component is focused.
-
clearFocus
public static void clearFocus()
Clears the focus.
-
load
public void load(java.lang.Object context)
Copies bound values from the bind context to the component. This functionality must be provided by the subclass; the base implementation is a no-op.- Parameters:
context- The object to load the bound values from.
-
store
public void store(java.lang.Object context)
Copies bound values from the component to the bind context. This functionality must be provided by the subclass; the base implementation is a no-op.- Parameters:
context- The object to store the bound values into.
-
clear
public void clear()
Clears any bound values in the component. This functionality must be provided by the subclass; the base implementation is a no-op.
-
getDragSource
public DragSource getDragSource()
-
setDragSource
public void setDragSource(DragSource dragSource)
-
getDropTarget
public DropTarget getDropTarget()
-
setDropTarget
public void setDropTarget(DropTarget dropTarget)
-
getMenuHandler
public MenuHandler getMenuHandler()
-
setMenuHandler
public void setMenuHandler(MenuHandler menuHandler)
-
getName
public java.lang.String getName()
- Returns:
- The name of the component.
-
setName
public void setName(java.lang.String name)
Sets the component's name.- Parameters:
name- Name to be given to this component.
-
getStyles
public final Component.StyleDictionary getStyles()
- Returns:
- The style dictionary for this component.
-
getStyle
public final java.lang.Object getStyle(Style style)
Get the style value corresponding to the given style key.- Parameters:
style- The enumerated style key.- Returns:
- The value for this style.
-
getStyle
public final java.lang.Object getStyle(java.lang.String style)
Get the style value corresponding to the given style key.- Parameters:
style- The style key.- Returns:
- The value for this style.
-
getStyleColor
public java.awt.Color getStyleColor(Style style)
Get the color value corresponding to the given style key.- Parameters:
style- The enumerated style key.- Returns:
- The color value for that style.
-
getStyleColor
public java.awt.Color getStyleColor(java.lang.String style)
Get the color value corresponding to the given style key.- Parameters:
style- The style key.- Returns:
- The color value for that style.
-
getStyleFont
public java.awt.Font getStyleFont(Style style)
Get the font value corresponding to the given style key.- Parameters:
style- The enumerated style key.- Returns:
- The font value for that style.
-
getStyleFont
public java.awt.Font getStyleFont(java.lang.String style)
Get the font value corresponding to the given style key.- Parameters:
style- The style key.- Returns:
- The font value for that style.
-
getStyleInt
public int getStyleInt(Style style)
Get the integer value corresponding to the given style key.- Parameters:
style- The enumerated style key.- Returns:
- The integer value for that style.
-
getStyleInt
public int getStyleInt(java.lang.String style)
Get the integer value corresponding to the given style key.- Parameters:
style- The style key.- Returns:
- The integer value for that style.
-
getStyleBoolean
public boolean getStyleBoolean(Style style)
Get the boolean value corresponding to the given style key.- Parameters:
style- The enumerated style key.- Returns:
- The boolean value for that style.
-
getStyleBoolean
public boolean getStyleBoolean(java.lang.String style)
Get the boolean value corresponding to the given style key.- Parameters:
style- The style key.- Returns:
- The boolean value for that style.
-
putStyle
public final void putStyle(Style style, java.lang.Object value)
Put the given key/value style into the style dictionary.- Parameters:
style- The enumerated style key.value- The value for this style.
-
putStyle
public final void putStyle(java.lang.String style, java.lang.Object value)Put the given key/value style into the style dictionary.- Parameters:
style- The style key.value- The value for this style.
-
copyStyle
public final void copyStyle(Style style, Component comp)
Copy the given style from the other component to this one.- Parameters:
style- The enumerated style key.comp- The other component to copy the style from.
-
copyStyle
public final void copyStyle(java.lang.String style, Component comp)Copy the given style from the other component to this one.- Parameters:
style- The style key.comp- The other component to copy the style from.
-
setStyles
public void setStyles(Map<java.lang.String,?> styles)
Applies a set of styles.- Parameters:
styles- A map containing the styles to apply.
-
setStyles
public void setStyles(java.lang.String styles) throws SerializationExceptionApplies a set of styles.- Parameters:
styles- The styles encoded as a JSON map.- Throws:
SerializationException- if the string doesn't conform to JSON standards.
-
getTypedStyles
public static Map<java.lang.Class<? extends Component>,Map<java.lang.String,?>> getTypedStyles()
- Returns:
- The typed style dictionary for this component.
-
getNamedStyles
public static Map<java.lang.String,Map<java.lang.String,?>> getNamedStyles()
- Returns:
- The named style dictionary for this component.
-
setStyleName
public void setStyleName(java.lang.String styleName)
Applies a named style to this component.- Parameters:
styleName- The name of an already loaded style to apply.
-
setStyleNames
public void setStyleNames(Sequence<java.lang.String> styleNames)
Applies a set of named styles.- Parameters:
styleNames- List of style names to apply to this component.
-
setStyleNames
public void setStyleNames(java.lang.String styleNames)
Applies a set of named styles.- Parameters:
styleNames- Comma-delimited list of style names to apply.
-
getUserData
public Component.UserDataDictionary getUserData()
- Returns:
- The user data dictionary for this component.
-
getAttribute
public <T extends java.lang.Enum<T>> java.lang.Object getAttribute(T key)
Gets the specified component attribute. While attributes can be used to store arbitrary data, they are intended to be used by containers to store layout-related metadata in their child components.- Type Parameters:
T- The enum type of the attribute key.- Parameters:
key- The attribute key- Returns:
- The attribute value, or
nullif no such attribute exists
-
setAttribute
public <T extends java.lang.Enum<T>> java.lang.Object setAttribute(T key, java.lang.Object value)Sets the specified component attribute. While attributes can be used to store arbitrary data, they are intended to be used by containers to store layout-related metadata in their child components.- Type Parameters:
T- The enum type of the attribute key.- Parameters:
key- The attribute keyvalue- The attribute value, ornullto clear the attribute- Returns:
- The previous value of the attribute, or
nullif the attribute was unset
-
reenterMouse
public void reenterMouse()
If the mouse is currently over the component, causes the component to firemouseOut()and amouseMove()at the current mouse location.This method is primarily useful when consuming container mouse motion events, since it allows a caller to reset the mouse state based on the event consumption logic.
-
mouseMove
protected boolean mouseMove(int xValue, int yValue)
-
mouseOver
protected void mouseOver()
-
mouseOut
protected void mouseOut()
-
mouseDown
protected boolean mouseDown(Mouse.Button button, int xValue, int yValue)
-
mouseUp
protected boolean mouseUp(Mouse.Button button, int xValue, int yValue)
-
mouseClick
protected boolean mouseClick(Mouse.Button button, int xValue, int yValue, int count)
-
mouseWheel
protected boolean mouseWheel(Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int xValue, int yValue)
-
keyTyped
protected boolean keyTyped(char character)
-
keyPressed
protected boolean keyPressed(int keyCode, Keyboard.KeyLocation keyLocation)
-
keyReleased
protected boolean keyReleased(int keyCode, Keyboard.KeyLocation keyLocation)
-
getTextInputMethodListener
public TextInputMethodListener getTextInputMethodListener()
Returns the input method listener for this component, which will reside in the skin, so defer to the skin class.- Returns:
- The input method listener (if any) for this component.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getComponentListeners
public ListenerList<ComponentListener> getComponentListeners()
-
getComponentStateListeners
public ListenerList<ComponentStateListener> getComponentStateListeners()
-
getComponentDecoratorListeners
public ListenerList<ComponentDecoratorListener> getComponentDecoratorListeners()
-
getComponentStyleListeners
public ListenerList<ComponentStyleListener> getComponentStyleListeners()
-
getComponentMouseListeners
public ListenerList<ComponentMouseListener> getComponentMouseListeners()
-
getComponentMouseButtonListeners
public ListenerList<ComponentMouseButtonListener> getComponentMouseButtonListeners()
-
getComponentMouseWheelListeners
public ListenerList<ComponentMouseWheelListener> getComponentMouseWheelListeners()
-
getComponentKeyListeners
public ListenerList<ComponentKeyListener> getComponentKeyListeners()
-
getComponentTooltipListeners
public ListenerList<ComponentTooltipListener> getComponentTooltipListeners()
-
getComponentDataListeners
public ListenerList<ComponentDataListener> getComponentDataListeners()
-
getComponentClassListeners
public static ListenerList<ComponentClassListener> getComponentClassListeners()
-
indexBoundsCheck
protected static final void indexBoundsCheck(java.lang.String indexName, int index, int min, int max)Check an index value against the provided bounds and throw a nicely formatted exception, including the index name, for out of range values. Index must be in the range of[min..max].- Parameters:
indexName- The name of the index to be checked.index- Index to be checked against the bounds.min- Minimum allowed value of the index.max- Maximum allowed value of the index.- Throws:
java.lang.IllegalArgumentException- if givenmax < min.java.lang.IndexOutOfBoundsException- if index is out of range (index < minorindex > max).
-
-