Class TabDelegate
JTabbedPane
delegate providing useful context information to various Action
listeners
used by UIForTabbedPane.onTabMouseClick(Action)
, UIForTabbedPane.onTabMousePress(Action)
and
UIForTabbedPane.onTabMouseRelease(Action)
, for example.
Not only does this delegate provide access to the
JTabbedPane
component itself, but also to the
MouseEvent
that triggered the event and the index of the clicked tab.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected JTabbedPane
protected final boolean
_isUndefinedColor
(Color color) protected final boolean
_isUndefinedFont
(Font font) protected List<JComponent>
final Animator
animateFor
(double duration, TimeUnit unit) Exposes access the animation builder API, where you can define the conditions under which the animation should be executed and then dispatch the animation to the EDT through theAnimator.go(Animation)
method.final void
animateFor
(double duration, TimeUnit unit, Animation animation) Use this to schedule and run the provided animation to be executed on the EDT.final Animator
animateFor
(LifeTime lifeTime) Exposes access the animation builder API, where you can define the conditions under which the animation should be executed and then dispatch the animation to the EDT through theAnimator.go(Animation)
method.final void
animateFor
(LifeTime lifeTime, Animation animation) Use this to schedule and run the provided animation to be executed on the EDT.final void
animateStyleFor
(double duration, TimeUnit unit, AnimatedStyler<JTabbedPane> styler) A common use case is to animate the style of a component when a user event occurs.final void
animateStyleFor
(LifeTime lifetime, AnimatedStyler<JTabbedPane> styler) A common use case is to animate the style of a component when a user event occurs.final <T extends JComponent>
OptionalUI<T>Use this to query the UI tree and find anyJComponent
of a particular type and id (the name of the component).final <T extends JComponent>
OptionalUI<T>Use this to query the UI tree and find anyJComponent
of a particular type and id (the name of the component).final <T extends JComponent>
OptionalUI<T>Use this to query the UI tree and find anyJComponent
based on a specific type and a predicate which is used to test if a particular component in the tree is the one you are looking for.final <T extends JComponent>
List<T>Use this to query the UI tree and find allJComponent
s based on a specific type and a predicate which is used to test if a particular component in the tree is the one you are looking for.final <T extends JComponent>
List<T>findAllByGroup
(Class<T> type, Enum<?> group) Use this to query the UI tree and find allJComponent
s of a particular type and also that belong to a particular style group.final <T extends JComponent>
List<T>findAllByGroup
(Class<T> type, String group) Use this to query the UI tree and find allJComponent
s of a particular type and also that belong to a particular style group.final List<JComponent>
findAllByGroup
(Enum<?> group) Use this to query the UI tree and find allJComponent
s that belong to a particular style group.final List<JComponent>
findAllByGroup
(String group) Use this to query the UI tree and find allJComponent
s that belong to a particular style group.final JTabbedPane
get()
This is a delegate to the underlying component, but not every method of the component is delegated.final Color
As a delegate to the underlying component, you can use this method to conveniently get the background color of the component.final Border
As a delegate to the underlying component, you can use this method to conveniently get the border of the component.final Rectangle
As a delegate to the underlying component, you can use this method to conveniently get the bounds of the component.final Cursor
As a delegate to the underlying component, you can use this method to conveniently get theCursor
of the component.final Font
getFont()
As a delegate to the underlying component, you can use this method to conveniently get the font of the component.final Color
As a delegate to the underlying component, you can use this method to conveniently get the foreground color of the component.final int
As a delegate to the underlying component, you can use this method to conveniently get the height of the component.final Point
As a delegate to the underlying component, you can use this method to conveniently access the location of the component relative to its parent in the form of aPoint
object.final Size
As a delegate to the underlying component, you can use this method to conveniently get the maximum size of the component.final Size
As a delegate to the underlying component, you can use this method to conveniently get the minimum size of the component.final Container
This is class a delegate API, which means that it represents the API of a wrapped component.final Size
As a delegate to the underlying component, you can use this method to conveniently get the preferred size of the component.float
getScale()
The number returned by this method is used to scale the UI to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).final Size
getSize()
As a delegate to the underlying component, you can use this method to conveniently get the size of the component.final String
As a delegate to the underlying component, you can use this method to conveniently get the tooltip of the component.final int
getWidth()
As a delegate to the underlying component, you can use this method to conveniently get the width of the component.final int
getX()
As a delegate to the underlying component, you can use this method to conveniently access the x-coordinate of the component relative to its parent.final int
getY()
As a delegate to the underlying component, you can use this method to conveniently access the y-coordinate of the component relative to its parent.final boolean
As a delegate to the underlying component, you can use this method to conveniently check if the component is enabled.final boolean
isOpaque()
As a delegate to the underlying component, you can use this method to conveniently check if the component is opaque.final boolean
As a delegate to the underlying component, you can use this method to conveniently check if the component is visible.final void
paint
(AnimationState state, Painter painter) A common use case is to render something on top of the component using theGraphics2D
instance of the component.final void
paint
(UI.ComponentArea area, AnimationState state, Painter painter) A common use case is to render something on top of the component using theGraphics2D
instance of the component.float
scale()
The number returned by this method is used to scale the UI to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).double
scale
(double value) Use this method inside customPainter
implementations (seepaint(AnimationState, Painter)
) to scale adouble
value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).float
scale
(float value) Use this method inside customPainter
implementations (seepaint(AnimationState, Painter)
) to scale afloat
value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).int
scale
(int value) Use this method inside customPainter
implementations (seepaint(AnimationState, Painter)
) to scale anint
value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).final int
Exposes the index of the currently selected tab.final swingtree.AbstractDelegate<JTabbedPane>
setBackground
(Color color) As a delegate to the underlying component, you can use this method to conveniently set the background color of the component.final swingtree.AbstractDelegate<JTabbedPane>
setBackgroundColor
(double r, double g, double b) As a delegate to the underlying component, you can use this method to conveniently set the background color of the component.final swingtree.AbstractDelegate<JTabbedPane>
setBackgroundColor
(double r, double g, double b, double a) As a delegate to the underlying component, you can use this method to conveniently set the background color of the component.final swingtree.AbstractDelegate<JTabbedPane>
setBackgroundColor
(int r, int g, int b) As a delegate to the underlying component, you can use this method to conveniently set the background color of the component.final swingtree.AbstractDelegate<JTabbedPane>
setBackgroundColor
(int r, int g, int b, int a) As a delegate to the underlying component, you can use this method to conveniently set the background color of the component.final swingtree.AbstractDelegate<JTabbedPane>
As a delegate to the underlying component, you can use this method to conveniently set the border of the component.final swingtree.AbstractDelegate<JTabbedPane>
setBounds
(int x, int y, int width, int height) As a delegate to the underlying component, you can use this method to conveniently set the bounds of the component.final swingtree.AbstractDelegate<JTabbedPane>
As a delegate to the underlying component, you can use this method to conveniently set the bounds of the component.final swingtree.AbstractDelegate<JTabbedPane>
Delegates to theComponent.setBounds(int, int, int, int)
method of the underlying component.final swingtree.AbstractDelegate<JTabbedPane>
As a delegate to the underlying component, you can use this method to conveniently set theCursor
of the component.final swingtree.AbstractDelegate<JTabbedPane>
As a delegate to the underlying component, you can use this method to conveniently set theUI.Cursor
of the component.final swingtree.AbstractDelegate<JTabbedPane>
setEnabled
(boolean enabled) As a delegate to the underlying component, you can use this method to conveniently enable or disable the component.final swingtree.AbstractDelegate<JTabbedPane>
As a delegate to the underlying component, you can use this method to conveniently set the font of the component.final swingtree.AbstractDelegate<JTabbedPane>
setForeground
(Color color) As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component.final swingtree.AbstractDelegate<JTabbedPane>
setForegroundColor
(double r, double g, double b) As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component.final swingtree.AbstractDelegate<JTabbedPane>
setForegroundColor
(double r, double g, double b, double a) As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component.final swingtree.AbstractDelegate<JTabbedPane>
setForegroundColor
(int r, int g, int b) As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component.final swingtree.AbstractDelegate<JTabbedPane>
setForegroundColor
(int r, int g, int b, int a) As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component.final swingtree.AbstractDelegate<JTabbedPane>
setHeight
(int height) As a delegate to the underlying component, you can use this method to conveniently set the height of the component.final swingtree.AbstractDelegate<JTabbedPane>
setMaxHeight
(int height) As a delegate to the underlying component, you can use this method to conveniently set the maximum height of the component.final swingtree.AbstractDelegate<JTabbedPane>
setMaxSize
(int width, int height) As a delegate to the underlying component, you can use this method to conveniently set the maximum size of the component.final swingtree.AbstractDelegate<JTabbedPane>
setMaxSize
(Dimension size) As a delegate to the underlying component, you can use this method to conveniently set the maximum size of the component.final swingtree.AbstractDelegate<JTabbedPane>
setMaxSize
(Size size) As a delegate to the underlying component, you can use this method to conveniently set the maximum size of the component.final swingtree.AbstractDelegate<JTabbedPane>
setMaxWidth
(int width) As a delegate to the underlying component, you can use this method to conveniently set the maximum width of the component.final swingtree.AbstractDelegate<JTabbedPane>
setMinHeight
(int height) As a delegate to the underlying component, you can use this method to conveniently set the minimum height of the component.final swingtree.AbstractDelegate<JTabbedPane>
setMinSize
(int width, int height) As a delegate to the underlying component, you can use this method to conveniently set the minimum size of the component.final swingtree.AbstractDelegate<JTabbedPane>
setMinSize
(Dimension size) As a delegate to the underlying component, you can use this method to conveniently set the minimum size of the component.final swingtree.AbstractDelegate<JTabbedPane>
setMinSize
(Size size) As a delegate to the underlying component, you can use this method to conveniently set the minimum size of the component.final swingtree.AbstractDelegate<JTabbedPane>
setMinWidth
(int width) As a delegate to the underlying component, you can use this method to conveniently set the minimum width of the component.final swingtree.AbstractDelegate<JTabbedPane>
setOpaque
(boolean opaque) As a delegate to the underlying component, you can use this method to conveniently make the component opaque or transparent.final swingtree.AbstractDelegate<JTabbedPane>
setPrefHeight
(int height) As a delegate to the underlying component, you can use this method to conveniently set the preferred height of the component.final swingtree.AbstractDelegate<JTabbedPane>
setPrefSize
(int width, int height) As a delegate to the underlying component, you can use this method to conveniently set the preferred size of the component.final swingtree.AbstractDelegate<JTabbedPane>
setPrefSize
(Dimension size) As a delegate to the underlying component, you can use this method to conveniently set the preferred size of the component.final swingtree.AbstractDelegate<JTabbedPane>
setPrefSize
(Size size) As a delegate to the underlying component, you can use this method to conveniently set the preferred size of the component.final swingtree.AbstractDelegate<JTabbedPane>
setPrefWidth
(int width) As a delegate to the underlying component, you can use this method to conveniently set the preferred width of the component.final swingtree.AbstractDelegate<JTabbedPane>
setSize
(int width, int height) As a delegate to the underlying component, you can use this method to conveniently set the size of the component.final swingtree.AbstractDelegate<JTabbedPane>
As a delegate to the underlying component, you can use this method to conveniently set the size of the component.final swingtree.AbstractDelegate<JTabbedPane>
As a delegate to the underlying component, you can use this method to conveniently set the size of the component.final swingtree.AbstractDelegate<JTabbedPane>
setTooltip
(String text) As a delegate to the underlying component, you can use this method to conveniently set the tooltip of the component.final swingtree.AbstractDelegate<JTabbedPane>
setVisible
(boolean visible) As a delegate to the underlying component, you can use this method to conveniently enable or disable the component.final swingtree.AbstractDelegate<JTabbedPane>
setWidth
(int width) As a delegate to the underlying component, you can use this method to conveniently set the width of the component.final void
style
(AnimationState state, Styler<JTabbedPane> styler) A common use case is to style the component based on the current animation state.final JComponent
Use this to access the tab component of the delegated tab.final int
tabIndex()
Exposes the index of the currently delegated tab, in the form of an integer starting at 0.final boolean
Reports whether the clicked tab is the currently selected tab, which is determined by comparing the index of the clicked tab with the index of the currently selected tab.Methods inherited from class swingtree.ComponentMouseEventDelegate
clickCount, isAltDown, isCtrlDown, isLeftMouseButton, isMetaDown, isMiddleMouseButton, isRightMouseButton, isShiftDown, mouseX, mouseXOnScreen, mouseY, mouseYOnScreen
Methods inherited from class swingtree.ComponentDelegate
forComponent, forSiblinghood, forSiblinghoodOfType, forSiblings, forSiblingsOfType, getComponent, getEvent, getSiblinghood, getSiblinghoodOfType, getSiblings, getSiblingsOfType
-
Constructor Details
-
TabDelegate
-
-
Method Details
-
selectedTabIndex
public final int selectedTabIndex()Exposes the index of the currently selected tab.- Returns:
- The index of the clicked tab.
-
tabIndex
public final int tabIndex()Exposes the index of the currently delegated tab, in the form of an integer starting at 0. It represents the position of the tab in the array of all existing tabs within the underlyingJTabbedPane
.- Returns:
- The index of the clicked tab.
-
tabIsSelected
public final boolean tabIsSelected()Reports whether the clicked tab is the currently selected tab, which is determined by comparing the index of the clicked tab with the index of the currently selected tab.- Returns:
- True if the clicked tab is the currently selected tab.
-
tabComponent
Use this to access the tab component of the delegated tab.- Returns:
- The component of the clicked tab.
-
_isUndefinedFont
-
_isUndefinedColor
-
_component
-
_siblingsSource
-
get
This is a delegate to the underlying component, but not every method of the component is delegated. This method allows you to access the underlying component directly.Note that this method expects that the accessing thread is the event dispatch thread, not the application thread. If you want to access the component from the application thread, you should use
UI.run(() -> delegate.component())
.- Returns:
- The underlying component.
- Throws:
IllegalStateException
- If the accessing thread is not the event dispatch thread.
-
getX
public final int getX()As a delegate to the underlying component, you can use this method to conveniently access the x-coordinate of the component relative to its parent.- Returns:
- The x-coordinate of the component relative to its parent.
-
getY
public final int getY()As a delegate to the underlying component, you can use this method to conveniently access the y-coordinate of the component relative to its parent.- Returns:
- The y-coordinate of the component relative to its parent.
-
getLocation
As a delegate to the underlying component, you can use this method to conveniently access the location of the component relative to its parent in the form of aPoint
object. The value returned by this method is equal to the value returned bygetX()
andgetY()
.- Returns:
- The location of the component relative to its parent.
-
getParent
This is class a delegate API, which means that it represents the API of a wrapped component. This method allows you to access the parent of the underlying component. In essence, this is a delegate toComponent.getParent()
.- Returns:
- The parent
Container
of the underlying component. - Throws:
IllegalStateException
- If the accessing thread is not the event dispatch thread.
-
setBackground
As a delegate to the underlying component, you can use this method to conveniently set the background color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setBackground(Color)
for more information.- Parameters:
color
- The color that should be used to paint the background of the component. If this parameter isnull
then this component will inherit the background color of its parent.- Returns:
- The delegate itself.
-
setBackgroundColor
public final swingtree.AbstractDelegate<JTabbedPane> setBackgroundColor(double r, double g, double b) As a delegate to the underlying component, you can use this method to conveniently set the background color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setBackground(Color)
for more information.- Parameters:
r
- The red component of the color as a double between 0 and 1.g
- The green component of the color as a double between 0 and 1.b
- The blue component of the color as a double between 0 and 1.- Returns:
- The delegate itself.
-
setBackgroundColor
public final swingtree.AbstractDelegate<JTabbedPane> setBackgroundColor(double r, double g, double b, double a) As a delegate to the underlying component, you can use this method to conveniently set the background color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setBackground(Color)
for more information.- Parameters:
r
- The red component of the color as a double between 0 and 1.g
- The green component of the color as a double between 0 and 1.b
- The blue component of the color as a double between 0 and 1.a
- The alpha component of the color as a double between 0 and 1.- Returns:
- The delegate itself.
-
setBackgroundColor
As a delegate to the underlying component, you can use this method to conveniently set the background color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setBackground(Color)
for more information.- Parameters:
r
- The red component of the color as an integer between 0 and 255.g
- The green component of the color as an integer between 0 and 255.b
- The blue component of the color as an integer between 0 and 255.- Returns:
- The delegate itself.
-
setBackgroundColor
As a delegate to the underlying component, you can use this method to conveniently set the background color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setBackground(Color)
for more information.- Parameters:
r
- The red component of the color as an integer between 0 and 255.g
- The green component of the color as an integer between 0 and 255.b
- The blue component of the color as an integer between 0 and 255.a
- The alpha component of the color as an integer between 0 and 255.- Returns:
- The delegate itself.
-
getBackground
As a delegate to the underlying component, you can use this method to conveniently get the background color of the component.See
Component.getBackground()
for more information.- Returns:
- The background color of the component, or
UI.Color.UNDEFINED
if the component does not have a background color (i.e.Component.getBackground()
returnsnull
). The return value will never benull
.
-
setForeground
As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setForeground(Color)
for more information.- Parameters:
color
- The color that should be used to paint the foreground of the component. If this parameter isnull
then this component will inherit the foreground color of its parent.- Returns:
- The delegate itself.
-
getForeground
As a delegate to the underlying component, you can use this method to conveniently get the foreground color of the component.See
Component.getForeground()
for more information.- Returns:
- The foreground color of the component, or
UI.Color.UNDEFINED
if the component does not have a foreground color (i.e.Component.getForeground()
returnsnull
). The return value will never benull
.
-
setForegroundColor
public final swingtree.AbstractDelegate<JTabbedPane> setForegroundColor(double r, double g, double b) As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setForeground(Color)
for more information.- Parameters:
r
- The red component of the color as a double between 0 and 1.g
- The green component of the color as a double between 0 and 1.b
- The blue component of the color as a double between 0 and 1.- Returns:
- The delegate itself.
-
setForegroundColor
public final swingtree.AbstractDelegate<JTabbedPane> setForegroundColor(double r, double g, double b, double a) As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setForeground(Color)
for more information.- Parameters:
r
- The red component of the color as a double between 0 and 1.g
- The green component of the color as a double between 0 and 1.b
- The blue component of the color as a double between 0 and 1.a
- The alpha component of the color as a double between 0 and 1.- Returns:
- The delegate itself.
-
setForegroundColor
As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setForeground(Color)
for more information.- Parameters:
r
- The red component of the color as an integer between 0 and 255.g
- The green component of the color as an integer between 0 and 255.b
- The blue component of the color as an integer between 0 and 255.- Returns:
- The delegate itself.
-
setForegroundColor
As a delegate to the underlying component, you can use this method to conveniently set the foreground color of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setForeground(Color)
for more information.- Parameters:
r
- The red component of the color as an integer between 0 and 255.g
- The green component of the color as an integer between 0 and 255.b
- The blue component of the color as an integer between 0 and 255.a
- The alpha component of the color as an integer between 0 and 255.- Returns:
- The delegate itself.
-
setFont
As a delegate to the underlying component, you can use this method to conveniently set the font of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setFont(Font)
for more information.- Parameters:
font
- The font that should be used to paint the text of the component. If this parameter isUI.Font.UNDEFINED
then this component will inherit the font of its parent. Null is not allowed.- Returns:
- The delegate itself.
-
getFont
As a delegate to the underlying component, you can use this method to conveniently get the font of the component.See
Component.getFont()
for more information.- Returns:
- The font of the component.
-
setBorder
As a delegate to the underlying component, you can use this method to conveniently set the border of the component. This method returns the delegate itself, so you can chain calls to this method.Note that this method is a delegate to
JComponent.setBorder(Border)
.- Parameters:
border
- The border that should be used to paint the border of the component. If this parameter isnull
then this component will inherit the border of its parent.- Returns:
- The delegate itself.
-
getBorder
As a delegate to the underlying component, you can use this method to conveniently get the border of the component.Note that this method is a delegate to
JComponent.getBorder()
.- Returns:
- The border of the component.
-
setBounds
As a delegate to the underlying component, you can use this method to conveniently set the bounds of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setBounds(int, int, int, int)
for more information.- Parameters:
x
- The x coordinate of the new location of the component. This is relative to the component's parent.y
- The y coordinate of the new location of the component. This is relative to the component's parent.width
- The new width of the component.height
- The new height of the component.- Returns:
- The delegate itself, so you can chain calls to this method.
-
setBounds
Delegates to theComponent.setBounds(int, int, int, int)
method of the underlying component. The bounds consist of a location and a size which are relative to the component's parent.- Parameters:
bounds
- The new bounds of the component. This is relative to the component's parent.- Returns:
- The delegate itself, so you can chain calls to this method.
-
setBounds
As a delegate to the underlying component, you can use this method to conveniently set the bounds of the component. This method returns the delegate itself, so you can chain calls to this method.See
Component.setBounds(Rectangle)
for more information.- Parameters:
bounds
- The new bounds of the component. This is relative to the component's parent.- Returns:
- The delegate itself, so you can chain calls to this method.
-
getBounds
As a delegate to the underlying component, you can use this method to conveniently get the bounds of the component.See
Component.getBounds()
for more information.- Returns:
- The bounds of the component. This is relative to the component's parent.
-
setPrefSize
As a delegate to the underlying component, you can use this method to conveniently set the preferred size of the component. This method returns the delegate itself, so you can chain calls to this method. The preferred size is used by the layout manager to determine the size of the component.See
Component.setPreferredSize(Dimension)
for more information.- Parameters:
size
- The preferred size of the component.- Returns:
- The delegate itself.
-
setPrefSize
As a delegate to the underlying component, you can use this method to conveniently set the preferred size of the component. This method returns the delegate itself, so you can chain calls to this method. The preferred size is used by the layout manager to determine the size of the component.See
Component.setPreferredSize(Dimension)
for more information.- Parameters:
size
- The preferred size of the component.- Returns:
- The delegate itself.
-
setPrefSize
As a delegate to the underlying component, you can use this method to conveniently set the preferred size of the component. This method returns the delegate itself, so you can chain calls to this method. The preferred size is used by the layout manager to determine the size of the component.See
Component.setPreferredSize(Dimension)
for more information.- Parameters:
width
- The preferred width of the component.height
- The preferred height of the component.- Returns:
- The delegate itself.
-
setPrefWidth
As a delegate to the underlying component, you can use this method to conveniently set the preferred width of the component. This method returns the delegate itself, so you can chain calls to this method. The preferred size is used by the layout manager to determine the size of the component.See
Component.setPreferredSize(Dimension)
for more information.- Parameters:
width
- The preferred width of the component.- Returns:
- The delegate itself.
-
setPrefHeight
As a delegate to the underlying component, you can use this method to conveniently set the preferred height of the component. This method returns the delegate itself, so you can chain calls to this method. The preferred size is used by the layout manager to determine the size of the component.See
Component.setPreferredSize(Dimension)
for more information.- Parameters:
height
- The preferred height of the component.- Returns:
- The delegate itself.
-
getPrefSize
As a delegate to the underlying component, you can use this method to conveniently get the preferred size of the component. The preferred size is used by the layout manager to determine the size of the component.See
Component.getPreferredSize()
for more information.- Returns:
- The preferred size of the component.
-
setMinSize
As a delegate to the underlying component, you can use this method to conveniently set the minimum size of the component. This method returns the delegate itself, so you can chain calls to this method. The minimum size is used by the layout manager to determine the size of the component.See
Component.setMinimumSize(Dimension)
for more information.- Parameters:
size
- The minimum size of the component.- Returns:
- The delegate itself.
-
setMinSize
As a delegate to the underlying component, you can use this method to conveniently set the minimum size of the component. This method returns the delegate itself, so you can chain calls to this method. The minimum size is used by the layout manager to determine the size of the component.See
Component.setMinimumSize(Dimension)
for more information.- Parameters:
size
- The minimum size of the component.- Returns:
- The delegate itself.
-
setMinSize
As a delegate to the underlying component, you can use this method to conveniently set the minimum size of the component. This method returns the delegate itself, so you can chain calls to this method. The minimum size is used by the layout manager to determine the size of the component.See
Component.setMinimumSize(Dimension)
for more information.- Parameters:
width
- The minimum width of the component.height
- The minimum height of the component.- Returns:
- The delegate itself.
-
setMinWidth
As a delegate to the underlying component, you can use this method to conveniently set the minimum width of the component. This method returns the delegate itself, so you can chain calls to this method. The minimum size is used by the layout manager to determine the size of the component.See
Component.setMinimumSize(Dimension)
for more information.- Parameters:
width
- The minimum width of the component.- Returns:
- The delegate itself.
-
setMinHeight
As a delegate to the underlying component, you can use this method to conveniently set the minimum height of the component. This method returns the delegate itself, so you can chain calls to this method. The minimum size is used by the layout manager to determine the size of the component.See
Component.setMinimumSize(Dimension)
for more information.- Parameters:
height
- The minimum height of the component.- Returns:
- The delegate itself.
-
getMinSize
As a delegate to the underlying component, you can use this method to conveniently get the minimum size of the component. The minimum size is used by the layout manager to determine the size of the component.See
Component.getMinimumSize()
for more information.- Returns:
- The minimum size of the component.
-
setMaxSize
As a delegate to the underlying component, you can use this method to conveniently set the maximum size of the component. This method returns the delegate itself, so you can chain calls to this method. The maximum size is used by the layout manager to determine the size of the component.See
Component.setMaximumSize(Dimension)
for more information.- Parameters:
size
- The maximum size of the component.- Returns:
- The delegate itself.
-
setMaxSize
As a delegate to the underlying component, you can use this method to conveniently set the maximum size of the component. This method returns the delegate itself, so you can chain calls to this method. The maximum size is used by the layout manager to determine the size of the component.See
Component.setMaximumSize(Dimension)
for more information.- Parameters:
size
- The maximum size of the component.- Returns:
- The delegate itself.
-
setMaxSize
As a delegate to the underlying component, you can use this method to conveniently set the maximum size of the component. This method returns the delegate itself, so you can chain calls to this method. The maximum size is used by the layout manager to determine the size of the component.See
Component.setMaximumSize(Dimension)
for more information.- Parameters:
width
- The maximum width of the component.height
- The maximum height of the component.- Returns:
- The delegate itself.
-
setMaxWidth
As a delegate to the underlying component, you can use this method to conveniently set the maximum width of the component. This method returns the delegate itself, so you can chain calls to this method. The maximum size is used by the layout manager to determine the size of the component.See
Component.setMaximumSize(Dimension)
for more information.- Parameters:
width
- The maximum width of the component.- Returns:
- The delegate itself.
-
setMaxHeight
As a delegate to the underlying component, you can use this method to conveniently set the maximum height of the component. This method returns the delegate itself, so you can chain calls to this method. The maximum size is used by the layout manager to determine the size of the component.See
Component.setMaximumSize(Dimension)
for more information.- Parameters:
height
- The maximum height of the component.- Returns:
- The delegate itself.
-
getMaxSize
As a delegate to the underlying component, you can use this method to conveniently get the maximum size of the component. The maximum size is used by the layout manager to determine the size of the component.See
Component.getMaximumSize()
for more information.- Returns:
- The maximum size of the component.
-
setSize
As a delegate to the underlying component, you can use this method to conveniently set the size of the component. This method returns the delegate itself, so you can chain calls to this method. The size is used by the layout manager to determine the size of the component.See
Component.setSize(Dimension)
for more information.- Parameters:
size
- The size of the component.- Returns:
- The delegate itself.
-
setSize
As a delegate to the underlying component, you can use this method to conveniently set the size of the component. This method returns the delegate itself, so you can chain calls to this method. The size is used by the layout manager to determine the size of the component.See
Component.setSize(Dimension)
for more information.- Parameters:
size
- The size of the component.- Returns:
- The delegate itself.
-
setSize
As a delegate to the underlying component, you can use this method to conveniently set the size of the component. This method returns the delegate itself, so you can chain calls to this method. The size is used by the layout manager to determine the size of the component.See
Component.setSize(Dimension)
for more information.- Parameters:
width
- The width of the component.height
- The height of the component.- Returns:
- The delegate itself.
-
setWidth
As a delegate to the underlying component, you can use this method to conveniently set the width of the component. This method returns the delegate itself, so you can chain calls to this method. The size is used by the layout manager to determine the size of the component.See
Component.setSize(Dimension)
for more information.- Parameters:
width
- The width of the component.- Returns:
- The delegate itself.
-
setHeight
As a delegate to the underlying component, you can use this method to conveniently set the height of the component. This method returns the delegate itself, so you can chain calls to this method. The size is used by the layout manager to determine the size of the component.See
Component.setSize(Dimension)
for more information.- Parameters:
height
- The height of the component.- Returns:
- The delegate itself.
-
getSize
As a delegate to the underlying component, you can use this method to conveniently get the size of the component. The size is used by the layout manager to determine the size of the component.See
Component.getSize()
for more information.- Returns:
- The size of the component.
-
getWidth
public final int getWidth()As a delegate to the underlying component, you can use this method to conveniently get the width of the component. The size is used by the layout manager to determine the size of the component.See
Component.getSize()
for more information.- Returns:
- The width of the component.
-
getHeight
public final int getHeight()As a delegate to the underlying component, you can use this method to conveniently get the height of the component. The size is used by the layout manager to determine the size of the component.See
Component.getSize()
for more information.- Returns:
- The height of the component.
-
setCursor
As a delegate to the underlying component, you can use this method to conveniently set theUI.Cursor
of the component.- Parameters:
cursor
- TheUI.Cursor
which should be set.- Returns:
- The delegate itself.
-
setCursor
As a delegate to the underlying component, you can use this method to conveniently set theCursor
of the component.- Parameters:
cursor
- TheCursor
which should be set.- Returns:
- The delegate itself.
-
getCursor
As a delegate to the underlying component, you can use this method to conveniently get theCursor
of the component.- Returns:
- The
Cursor
of the component.
-
setTooltip
As a delegate to the underlying component, you can use this method to conveniently set the tooltip of the component. This method returns the delegate itself, so you can chain calls to this method.See
JComponent.setToolTipText(String)
for more information.- Parameters:
text
- The tooltip text.- Returns:
- The delegate itself.
- Throws:
NullPointerException
- If the text is null, use an empty string to model the absence of a tooltip.
-
getTooltip
As a delegate to the underlying component, you can use this method to conveniently get the tooltip of the component.See
JComponent.getToolTipText()
for more information.- Returns:
- The tooltip text.
-
setEnabled
As a delegate to the underlying component, you can use this method to conveniently enable or disable the component. This method returns the delegate itself, so you can chain calls to this method.See
JComponent.setEnabled(boolean)
for more information.- Parameters:
enabled
- True if the component should be enabled, false otherwise.- Returns:
- The delegate itself.
-
isEnabled
public final boolean isEnabled()As a delegate to the underlying component, you can use this method to conveniently check if the component is enabled.See
Component.isEnabled()
for more information.- Returns:
- True if the component is enabled, false otherwise.
-
setVisible
As a delegate to the underlying component, you can use this method to conveniently enable or disable the component. This method returns the delegate itself, so you can chain calls to this method.See
JComponent.setVisible(boolean)
for more information.- Parameters:
visible
- True if the component should be visible, false otherwise.- Returns:
- The delegate itself.
-
isVisible
public final boolean isVisible()As a delegate to the underlying component, you can use this method to conveniently check if the component is visible.See
Component.isVisible()
for more information.- Returns:
- True if the component is visible, false otherwise.
-
setOpaque
As a delegate to the underlying component, you can use this method to conveniently make the component opaque or transparent. This method returns the delegate itself, so you can chain calls to this method.See
JComponent.setOpaque(boolean)
for more information.- Parameters:
opaque
- True if the component should be opaque, false otherwise.- Returns:
- The delegate itself.
-
isOpaque
public final boolean isOpaque()As a delegate to the underlying component, you can use this method to conveniently check if the component is opaque.See
JComponent.isOpaque()
for more information.- Returns:
- True if the component is opaque, false otherwise.
-
find
Use this to query the UI tree and find anyJComponent
of a particular type and id (the name of the component).- Type Parameters:
T
- The type parameter of the component which should be found.- Parameters:
type
- TheJComponent
type which should be found in the swing tree.id
- The ide of theJComponent
which should be found in the swing tree.- Returns:
- An
Optional
instance which may or may not contain the requested component.
-
find
Use this to query the UI tree and find anyJComponent
of a particular type and id (the name of the component).- Type Parameters:
T
- The type parameter of the component which should be found.- Parameters:
type
- TheJComponent
type which should be found in the swing tree.id
- The ide of theJComponent
which should be found in the swing tree.- Returns:
- An
Optional
instance which may or may not contain the requested component.
-
find
Use this to query the UI tree and find anyJComponent
based on a specific type and a predicate which is used to test if a particular component in the tree is the one you are looking for.- Type Parameters:
T
- The type parameter of the component which should be found.- Parameters:
type
- TheJComponent
type which should be found in the swing tree.predicate
- The predicate which should be used to test theJComponent
.- Returns:
- An
Optional
instance which may or may not contain the requested component.
-
findAll
Use this to query the UI tree and find allJComponent
s based on a specific type and a predicate which is used to test if a particular component in the tree is the one you are looking for.- Type Parameters:
T
- The type parameter of the component which should be found.- Parameters:
type
- TheJComponent
type which should be found in the swing tree.predicate
- The predicate which should be used to test theJComponent
.- Returns:
- A list of
JComponent
instances which match the given type and predicate.
-
findAllByGroup
Use this to query the UI tree and find allJComponent
s of a particular type and also that belong to a particular style group.- Type Parameters:
T
- The type parameter of the component which should be found.- Parameters:
type
- TheJComponent
type which should be found in the swing tree.group
- The style group which should be used to test theJComponent
.- Returns:
- A list of
JComponent
instances which match the given type and group.
-
findAllByGroup
Use this to query the UI tree and find allJComponent
s that belong to a particular style group.- Parameters:
group
- The style group which should be used to check if a particularJComponent
belongs to it.- Returns:
- A list of
JComponent
instances which all have the given style group. - Throws:
NullPointerException
- If the group is null.
-
findAllByGroup
Use this to query the UI tree and find allJComponent
s of a particular type and also that belong to a particular style group.- Type Parameters:
T
- The type parameter of the component which should be found.- Parameters:
type
- TheJComponent
type which should be found in the swing tree.group
- The style group which should be used to test theJComponent
.- Returns:
- A list of
JComponent
instances which match the given type and predicate.
-
findAllByGroup
Use this to query the UI tree and find allJComponent
s that belong to a particular style group.- Parameters:
group
- The style group which should be used to check if a particularJComponent
belongs to it.- Returns:
- A list of
JComponent
instances which all have the given style group.
-
paint
A common use case is to render something on top of the component using theGraphics2D
instance of the component. This method allows you to attach a paint task to the component, which the EDT will process in the next repaint event cycle, and remove when the animation expires. This ensures that custom rendering is not erased by a potential repaint of the component after a user event.Here is an example of how to use this method as part of a fancy button animation:
You may also be interested in doing style animations, if so, maybe consider taking a look atUI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateFor(2, TimeUnit.SECONDS, state -> { double r = 300 * state.progress() * it.scale(); double x = it.mouseX() - r / 2; double y = it.mouseY() - r / 2; it.paint(state, g -> { g.setColor(new Color(1f, 1f, 0f, (float) (1 - state.progress()))); g.fillOval((int) x, (int) y, (int) r, (int) r); }); }))
UIForAnySwing.withTransitoryStyle(Event, LifeTime, AnimatedStyler)
to see how to do event based styling animations andUIForAnySwing.withTransitionalStyle(Val, LifeTime, AnimatedStyler)
to see how to do 2 state switch based styling animations.- Parameters:
state
- The current animation state, which is important so that the rendering can be synchronized with the animation.painter
- The rendering task which should be executed on the EDT at the end of the current event cycle.
-
paint
A common use case is to render something on top of the component using theGraphics2D
instance of the component. This method allows you to attach a paint task to the component, which the EDT will process in the next repaint event cycle, and remove when the animation expires. This ensures that custom rendering is not erased by a potential repaint of the component after a user event.
Additionally, you can specify the area of the component which should be painted.Here is an example of how to use this method as part of a button animation:
You may also be interested in doing style animations, if so, maybe consider taking a look atUI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateFor(2, TimeUnit.SECONDS, state -> { double r = 300 * state.progress() * it.scale(); double x = it.mouseX() - r / 2; double y = it.mouseY() - r / 2; it.paint(UI.ComponentArea.BORDER, state, g -> { g.setColor(new Color(1f, 1f, 0f, (float) (1 - state.progress()))); g.fillOval((int) x, (int) y, (int) r, (int) r); }); }))
UIForAnySwing.withTransitoryStyle(Event, LifeTime, AnimatedStyler)
to see how to do event based styling animations andUIForAnySwing.withTransitionalStyle(Val, LifeTime, AnimatedStyler)
to see how to do 2 state switch based styling animations.- Parameters:
area
- The area of the component which should be painted.state
- The current animation state, which is important so that the rendering can be synchronized with the animation.painter
- The rendering task which should be executed on the EDT at the end of the current event cycle.
-
animateStyleFor
public final void animateStyleFor(double duration, TimeUnit unit, AnimatedStyler<JTabbedPane> styler) A common use case is to animate the style of a component when a user event occurs. This method allows you to dispatch a styling animation to the EDT which will cause the component style to updated repeatedly until the animation expires. Because animation styles are applied last, it is guaranteed not to be overwritten by otherStyler
lambdas. Note that the provided styling will be removed automatically when the animation expires, so no manual cleanup is required.Here is an example of how to use this method as part of a fancy styling animation:
Not that the effect of this method can also be modelled usingUI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateStyleFor(2, TimeUnit.SECONDS, (state, style) -> .borderWidthAt(UI.Edge.BOTTOM, (int)(6 * state.progress()) ) .borderColor( new Color(0f, 1f, 1f, (float) (1 - state.progress())) ) .borderRadius( (int)(60 * state.progress()) ) ))
animateFor(LifeTime, Animation)
andstyle(AnimationState, Styler)
as follows:
Also seeUI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateFor(2, TimeUnit.SECONDS, state -> { it.style(state, style -> style // This is the same as the animateStyleFor() method above! ); }))
animateStyleFor(LifeTime, AnimatedStyler)
for a version of this method which uses aLifeTime
instead of a duration. If you are interested in doing more advanced style animations, consider taking a look atUIForAnySwing.withTransitoryStyle(Event, LifeTime, AnimatedStyler)
to see how to do event based styling animations andUIForAnySwing.withTransitionalStyle(Val, LifeTime, AnimatedStyler)
to see how to do 2 state switch based styling animations.- Parameters:
duration
- The duration of the animation.unit
- The time unit of the duration.styler
- The styling animation task which should be executed on the EDT at the end of the current event cycle. It receives both the current animation state and theComponentStyleDelegate
for which you can define the style properties.
-
animateStyleFor
A common use case is to animate the style of a component when a user event occurs. This method allows you to dispatch a styling animation to the EDT which will cause the component style to updated repeatedly until the animation expires. Because animation styles are applied last, it is guaranteed not to be overwritten by otherStyler
lambdas. Note that the provided styling will be removed automatically when the animation expires, so no manual cleanup is required.Here is an example of how to use this method as part of a fancy styling animation:
Not that the effect of this method can also be modelled usingUI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateStyleFor(UI.lifetime(2, TimeUnit.SECONDS), (state, style) -> .borderWidthAt(UI.Edge.BOTTOM, (int)(6 * state.progress()) ) .borderColor( new Color(0f, 1f, 1f, (float) (1 - state.progress())) ) .borderRadius( (int)(60 * state.progress()) ) ))
animateFor(LifeTime, Animation)
andstyle(AnimationState, Styler)
as follows:
Also seeUI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateFor(UI.lifetime(2, TimeUnit.SECONDS), state -> { it.style(state, style -> style // This is the same as the animateStyleFor() method above! ); }))
animateStyleFor(double, TimeUnit, AnimatedStyler)
for a version of this method which uses aLifeTime
instead of a duration. If you are interested in doing more advanced style animations, consider taking a look atUIForAnySwing.withTransitoryStyle(Event, LifeTime, AnimatedStyler)
to see how to do event based styling animations andUIForAnySwing.withTransitionalStyle(Val, LifeTime, AnimatedStyler)
to see how to do 2 state switch based styling animations.- Parameters:
lifetime
- The lifetime of the animation. The animation will be removed automatically when the lifetime expires.styler
- The styling animation task which should be executed on the EDT at the end of the current event cycle. It receives both the current animation state and theComponentStyleDelegate
for which you can define the style properties.
-
style
A common use case is to style the component based on the current animation state. This method allows you to dispatch a styling task to the EDT which will be executed before the next component repaint. Because animation styles are applied last, it is guaranteed not to be overwritten by other styles. The provided styling will be removed when the animation expires.Here is an example of how to use this method as part of a fancy styling animation:
UI.button("Click me").withPrefSize(400, 400) .onMouseClick( it -> it.animateFor(2, TimeUnit.SECONDS, state -> { it.style(state, style -> style .borderWidth((int)(10 * state.progress())) .borderColor(new Color(1f, 1f, 0f, (float) (1 - state.progress()))) .borderRadius((int)(100 * state.progress())) ); }))
- Parameters:
state
- The current animation state, which is important so that the styling can be synchronized with the animation.styler
- The styling task which should be executed on the EDT at the end of the current event cycle.
-
animateFor
Exposes access the animation builder API, where you can define the conditions under which the animation should be executed and then dispatch the animation to the EDT through theAnimator.go(Animation)
method.- Parameters:
duration
- The duration of the animation.unit
- The time unit of the duration.- Returns:
- An
Animator
instance which can be used to define how the animation should be executed.
-
animateFor
Exposes access the animation builder API, where you can define the conditions under which the animation should be executed and then dispatch the animation to the EDT through theAnimator.go(Animation)
method.- Parameters:
lifeTime
- The lifetime of the animation.- Returns:
- An
Animator
instance which can be used to define how the animation should be executed.
-
animateFor
Use this to schedule and run the provided animation to be executed on the EDT. A single animation iteration may be executed multiple times for the given duration in order to achieve a smooth transition.
Here an example of how to use this method on a "Save" button:UI.button("Save").withPrefSize(400, 400) .onMouseClick( it -> it .animateFor( UI.lifetime(1, TimeUnit.SECONDS) .startingIn( 0.5, TimeUnit.SECONDS ) ) .go( myAnimation ) )
- Parameters:
lifeTime
- The lifetime of the animation.animation
- The animation that should be executed.
-
animateFor
Use this to schedule and run the provided animation to be executed on the EDT. A single animation iteration may be executed multiple times for the given duration in order to achieve a smooth transition.- Parameters:
duration
- The duration of the animation.unit
- The time unit of the duration.animation
- The animation that should be executed.
-
getScale
public float getScale()The number returned by this method is used to scale the UI to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI). Use it inside customPainter
implementations (seepaint(AnimationState, Painter)
) to scale customGraphics2D
painting operations.- Returns:
- The current UI scale factor, which is used to scale the UI for high resolution displays (high dots-per-inch, or DPI).
-
scale
public float scale()The number returned by this method is used to scale the UI to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI). Use it inside customPainter
implementations (seepaint(AnimationState, Painter)
) to scale customGraphics2D
painting operations.- Returns:
- The current UI scale factor, which is used to scale the UI for high resolution displays (high dots-per-inch, or DPI).
-
scale
public int scale(int value) Use this method inside customPainter
implementations (seepaint(AnimationState, Painter)
) to scale anint
value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).- Parameters:
value
- Theint
value to scale.- Returns:
- The scaled
int
value.
-
scale
public float scale(float value) Use this method inside customPainter
implementations (seepaint(AnimationState, Painter)
) to scale afloat
value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).- Parameters:
value
- Thefloat
value to scale.- Returns:
- The scaled
float
value.
-
scale
public double scale(double value) Use this method inside customPainter
implementations (seepaint(AnimationState, Painter)
) to scale adouble
value by the current UI scale factor to ensure that the UI is scaled properly for high resolution displays (high dots-per-inch, or DPI).- Parameters:
value
- Thedouble
value to scale.- Returns:
- The scaled
double
value.
-