Package swingtree.style
Interface StylableComponent
- All Known Implementing Classes:
JBox
,JGlassPane
,JIcon
,JScrollPanels
,JScrollPanels.EntryPanel
,JSplitButton
,UI.Box
,UI.Button
,UI.CheckBox
,UI.CheckBoxMenuItem
,UI.ComboBox
,UI.Component
,UI.EditorPane
,UI.FormattedTextField
,UI.Label
,UI.List
,UI.Menu
,UI.MenuBar
,UI.MenuItem
,UI.Panel
,UI.PasswordField
,UI.PopupMenu
,UI.ProgressBar
,UI.RadioButton
,UI.RadioButtonMenuItem
,UI.ScrollPane
,UI.Slider
,UI.Spinner
,UI.SplitButton
,UI.SplitPane
,UI.TabbedPane
,UI.Table
,UI.TableHeader
,UI.TextArea
,UI.TextField
,UI.TextPane
,UI.ToggleButton
,UI.ToolBar
,UI.ToolTip
,UI.Tree
public interface StylableComponent
Implementations of this interface are SwingTree native components
which enjoy the full support of the style API.
Regular Swing components can be styled on most layers
but not all. The
This however is prone to side effects and can cause issues with third party look and feels.
For full support of the style API for your custom components you should implement this interface.
UI.Layer.BACKGROUND
and
UI.Layer.FOREGROUND
layers are not supported
for some components for which SwingTree tries to install a
custom UI delegate. This however is prone to side effects and can cause issues with third party look and feels.
For full support of the style API for your custom components you should implement this interface.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method is expected to be implemented as follows within a component extension which ought to be made compatible with SwingTree.default void
paintBackground
(Graphics g, Consumer<Graphics> superPaint) This default method is not intended to be overridden by client code! It delegates the painting to the library internalComponentExtension
.void
This method is expected to be implemented as follows:default void
paintForeground
(Graphics g, Consumer<Graphics> superPaint) This default method is not intended to be overridden by client code! It delegates the painting to the library internalComponentExtension
.void
Certain style configurations require SwingTree to install a custom UI delegate.
-
Method Details
-
setUISilently
Certain style configurations require SwingTree to install a custom UI delegate. This method is used to set the UI delegate for the component but without triggering side effects like the former UI being uninstalled (which itself can cause a lot of undesired side effects).This method is not intended to be called by client code! It exists for internal use only and unfortunately cannot be protected or private due to the nature of the Swing API.
The implementation of this method is expected to look like this:
@Override public void setUISilently(ComponentUI ui){ this.ui = ui; // no side effects }
- Parameters:
ui
- the UI delegate to set for the component without triggering side effects.
-
paint
This method is expected to be implemented as follows within a component extension which ought to be made compatible with SwingTree.@Override public void paint(Graphics g){ paintBackground(g, ()->super.paint(g)); }
- Parameters:
g
- the graphics context to paint on, obtained from the component'sJComponent.paint(Graphics)
method.
-
paintChildren
This method is expected to be implemented as follows:@Override public void paintChildren(Graphics g){ paintForeground(g, ()->super.paintChildren(g)); }
- Parameters:
g
- the graphics context to paint on, obtained from the component'sJComponent::paintChildren(Graphics)
method.
-
paintBackground
This default method is not intended to be overridden by client code! It delegates the painting to the library internalComponentExtension
.- Parameters:
g
- The graphics context to paint on.superPaint
- The super.paint() method to call.
-
paintForeground
This default method is not intended to be overridden by client code! It delegates the painting to the library internalComponentExtension
.- Parameters:
g
- The graphics context to paint on.superPaint
- The super.paintChildren() method to call.
-