class SwingBuilder
extends FactoryBuilderSupport
Builder that exposes Swing components, layouts, bindings, and threading helpers through a Groovy DSL.
| Type | Name and description |
|---|---|
static String |
DEFAULT_DELEGATE_PROPERTY_OBJECT_IDDefault attribute name used when no custom delegate property id is configured. |
static String |
DELEGATE_PROPERTY_OBJECT_IDContext key containing the attribute name used to publish created nodes as builder variables. |
| Constructor and description |
|---|
SwingBuilder(boolean init)Creates a new Swing builder and optionally performs the default initialization. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
Object |
build(Closure c)Executes a closure against this builder for compatibility with older APIs. |
|
static Object |
clientPropertyAttributeDelegate(Object builder, Object node, Object attributes)Applies clientProperties and clientProperty* attributes to the target component. |
|
void |
createKeyStrokeAction(Map attributes, JComponent component)Binds one or more keystrokes to an action on the resolved target component. |
|
SwingBuilder |
doLater(Closure c)Schedules a closure to run on the Event Dispatch Thread using SwingUtilities.invokeLater. |
|
SwingBuilder |
doOutside(Closure c)Runs a closure outside of the Event Dispatch Thread. |
|
SwingBuilder |
edt(Closure c)Runs a closure on the Event Dispatch Thread using SwingUtilities.invokeAndWait when needed. |
|
static SwingBuilder |
edtBuilder(Closure c)Creates a new builder and runs the supplied closure on the EDT. |
|
static LookAndFeel |
lookAndFeel(Object laf, Closure initCode)Resolves and installs a look and feel with an optional initialization closure. |
|
static LookAndFeel |
lookAndFeel(Map attributes, Object laf, Closure initCode)Resolves and installs a look and feel with optional attributes and initialization logic. |
|
static LookAndFeel |
lookAndFeel(Object[] lafs)Attempts multiple look and feel candidates until one installs successfully. |
|
static Object |
objectIDAttributeDelegate(Object builder, Object node, Object attributes)Publishes created nodes into the builder variable namespace using the configured id attribute. |
|
Object |
registerActionButtonWidgets()Registers button-like widgets that can share Swing actions. |
|
Object |
registerBasicLayouts()Registers core Swing layout managers and their attribute delegates. |
|
Object |
registerBasicWidgets()Registers basic selection and value widgets. |
|
void |
registerBeanFactory(String nodeName, String groupName, Class klass)Registers a bean factory, substituting Swing-specific factory implementations for special component types. |
|
Object |
registerBinding()Registers binding-related factories and delegates. |
|
Object |
registerBorders()Registers border factories. |
|
Object |
registerBoxLayout()Registers BoxLayout-based containers and spacing helpers. |
|
Object |
registerContainers()Registers container widgets that can host child components. |
|
Object |
registerDataModels()Registers standard Swing data model nodes. |
|
Object |
registerEditors()Registers cell editor factories. |
|
Object |
registerMDIWidgets()Registers desktop and internal-frame widgets used for MDI applications. |
|
Object |
registerMenuWidgets()Registers menu-related widgets. |
|
Object |
registerPassThruNodes()Registers pass-through nodes that wrap existing beans or components. |
|
Object |
registerRenderers()Registers renderer factories for tables, lists, and headers. |
|
Object |
registerSupportNodes()Registers support nodes, explicit methods, and attribute delegates that do not create visible widgets. |
|
Object |
registerTableComponents()Registers tables, columns, and table model helper nodes. |
|
Object |
registerTableLayout()Registers table-layout nodes. |
|
Object |
registerTextWidgets()Registers text-oriented Swing widgets. |
|
Object |
registerThreading()Registers threading helper methods such as edt and doLater. |
|
Object |
registerWindows()Registers top-level window factories. |
|
KeyStroke |
shortcut(Object key, Object modifier)Creates a menu-shortcut keystroke for the supplied key and additional modifiers. |
|
KeyStroke |
shortcut(String key, Object modifier)Creates a menu-shortcut keystroke from a string description. |
Default attribute name used when no custom delegate property id is configured.
Context key containing the attribute name used to publish created nodes as builder variables.
Creates a new Swing builder and optionally performs the default initialization.
init - whether superclass initialization should run immediatelyExecutes a closure against this builder for compatibility with older APIs.
c - the closure to execute Applies clientProperties and clientProperty* attributes to the target component.
builder - the active buildernode - the component receiving client propertiesattributes - the node attributes to inspect and mutateBinds one or more keystrokes to an action on the resolved target component.
The target component is taken from the method argument, a component: attribute,
or the current builder node. Unknown conditions default to JComponent.WHEN_FOCUSED.
attributes - action registration attributescomponent - optional explicit target componentSchedules a closure to run on the Event Dispatch Thread using SwingUtilities.invokeLater.
When running headless, the closure executes immediately.
c - the closure to run on the EDTRuns a closure outside of the Event Dispatch Thread.
If called from the EDT a new thread is started immediately; otherwise the closure runs in the current thread.
c - the closure to run outside the EDTRuns a closure on the Event Dispatch Thread using SwingUtilities.invokeAndWait when needed.
When already on the EDT, or when running headless, the closure executes immediately.
c - the closure to run on the EDTCreates a new builder and runs the supplied closure on the EDT.
c - the closure to execute with the new builderResolves and installs a look and feel with an optional initialization closure.
laf - the look and feel instance, alias, or class nameinitCode - optional initialization closureResolves and installs a look and feel with optional attributes and initialization logic.
attributes - look and feel configuration attributeslaf - the look and feel instance, alias, or class nameinitCode - optional initialization closureAttempts multiple look and feel candidates until one installs successfully.
lafs - the look and feel candidates to trynull if all candidates failPublishes created nodes into the builder variable namespace using the configured id attribute.
builder - the active buildernode - the created nodeattributes - the node attributes to inspect and mutateRegisters button-like widgets that can share Swing actions.
Registers core Swing layout managers and their attribute delegates.
Registers basic selection and value widgets.
Registers a bean factory, substituting Swing-specific factory implementations for special component types.
nodeName - the builder node namegroupName - the factory group nameklass - the bean class to registerRegisters binding-related factories and delegates.
Registers border factories.
Registers BoxLayout-based containers and spacing helpers.
Registers container widgets that can host child components.
Registers standard Swing data model nodes.
Registers cell editor factories.
Registers desktop and internal-frame widgets used for MDI applications.
Registers menu-related widgets.
Registers pass-through nodes that wrap existing beans or components.
Registers renderer factories for tables, lists, and headers.
Registers support nodes, explicit methods, and attribute delegates that do not create visible widgets.
Registers tables, columns, and table model helper nodes.
Registers table-layout nodes.
Registers text-oriented Swing widgets.
Registers threading helper methods such as edt and doLater.
Registers top-level window factories.
Creates a menu-shortcut keystroke for the supplied key and additional modifiers.
key - the key specification accepted by KeyStroke.getKeyStrokemodifier - additional modifier mask bitsCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.