public final class ListViewBuilder extends Object
Examples:
return ListViewBuilder.create() .labelText("&Contacts:") .listView(contactsTable) .listBar(newButton, editButton, deleteButton) .build(); return ListViewBuilder.create() .padding(Paddings.DLU14) .label(contactsLabel) .filterView(contactsSearchField) .listView(contactsTable) .listBar(newButton, editButton, deleteButton, null, printButton) .detailsView(contactDetailsView) .build();For more examples see the JGoodies Showcase application.
Modifier and Type | Method and Description |
---|---|
ListViewBuilder |
border(Border border)
Sets an optional border that surrounds the list view including
the label and details.
|
JComponent |
build()
Lazily builds and returns the list view panel.
|
static ListViewBuilder |
create()
Creates and returns a ListViewBuilder using the global default
component factory.
|
ListViewBuilder |
detailsView(JComponent detailsView)
Sets an optional details view that is located under the list view.
|
ListViewBuilder |
factory(ComponentFactory factory)
Sets
factory as this builder's new component factory
that is used to create the label or header components. |
ListViewBuilder |
filterView(JComponent filterView)
Sets an optional view that will be placed in the upper right corner
of the built list view panel.
|
ListViewBuilder |
filterViewColumn(String colSpec,
Object... args)
Changes the FormLayout column specification used to lay out
the filter view.
|
ListViewBuilder |
focusTraversalPolicy(FocusTraversalPolicy policy)
Sets the panel's focus traversal policy and sets the panel
as focus traversal policy provider.
|
ListViewBuilder |
focusTraversalType(FocusTraversalType focusTraversalType) |
ListViewBuilder |
headerText(String markedText,
Object... args)
Creates a header label for the given marked text and sets it as label view.
|
ListViewBuilder |
honorVisibility(boolean b)
Specifies whether invisible components shall be taken into account by
this builder for computing the layout size and setting component bounds.
|
ListViewBuilder |
initialComponent(JComponent initialComponent)
Sets the component that shall receive the focus if this panel's
parent is made visible the first time.
|
ListViewBuilder |
label(JComponent labelView)
Sets the mandatory label view.
|
ListViewBuilder |
labelText(String markedText,
Object... args)
Creates a plain label for the given marked text and sets it as label view.
|
ListViewBuilder |
listBar(JComponent... buttons)
Builds a button bar using the given buttons and sets it as list bar.
|
ListViewBuilder |
listBarView(JComponent listBarView)
Sets an optional list bar - often a button bar -
that will be located in the lower left corner of the list view.
|
ListViewBuilder |
listExtrasView(JComponent listExtrasView)
Sets an optional view that is located in the lower right corner
of the list view, aligned with the list bar.
|
ListViewBuilder |
listStack(JComponent... buttons)
Builds a button stack using the given buttons and sets it as list stack.
|
ListViewBuilder |
listStackView(JComponent listStackView)
Sets an optional list stack - often a stack of buttons -
that will be located on the right-hand side of the list view.
|
ListViewBuilder |
listView(JComponent listView)
Sets the given component as the the mandatory list view.
|
ListViewBuilder |
listViewRow(String rowSpec,
Object... args)
Changes the FormLayout row specification used to lay out the list view.
|
ListViewBuilder |
namePrefix(String namePrefix)
Sets the prefix that is prepended to the component name of components
that have no name set or that are are implicitly created by this builder,
e.g. the (header) label.
|
ListViewBuilder |
padding(EmptyBorder padding)
Sets an optional padding (an empty border) that surrounds the list view
including the label and details.
|
ListViewBuilder |
padding(String paddingSpec,
Object... args)
Sets the panel's padding as an EmptyBorder using the given specification
for the top, left, bottom, right margins in DLU.
|
public static ListViewBuilder create()
labelText(String, Object...)
and
headerText(String, Object...)
.public ListViewBuilder border(Border border)
border
- the border to setpublic ListViewBuilder padding(EmptyBorder padding)
padding
- the white space to use around the list view panelpublic ListViewBuilder padding(String paddingSpec, Object... args)
Equivalent to padding(Paddings.createPadding(paddingSpec, args))
.
paddingSpec
- describes the top, left, bottom, right margins
of the padding (an EmptyBorder) to useargs
- optional format arguments,
used if paddingSpec
is a format stringpadding(EmptyBorder)
,
Paddings.createPadding(String, Object...)
public ListViewBuilder initialComponent(JComponent initialComponent)
initialComponent
- the component that shall receive the focus
if the panel is made visible the first timefocusTraversalType(FocusTraversalType)
public ListViewBuilder focusTraversalType(FocusTraversalType focusTraversalType)
focusTraversalType
- either: layout or container orderinitialComponent(JComponent)
public ListViewBuilder focusTraversalPolicy(FocusTraversalPolicy policy)
builder.getPanel().setFocusTraversalPolicy(policy); builder.getPanel().setFocusTraversalPolicyProvider(true);
policy
- the focus traversal policy that will manage
keyboard traversal of the children in this builder's panelContainer.setFocusTraversalPolicy(FocusTraversalPolicy)
,
Container.setFocusTraversalPolicyProvider(boolean)
public ListViewBuilder honorVisibility(boolean b)
true
invisible components will be ignored by
the layout. If set to false
components will be taken into
account regardless of their visibility. Visible components are always
used for sizing and positioning.
The default value for this setting is true
.
It is useful to set the value to false
(in other words
to ignore the visibility) if you switch the component visibility
dynamically and want the container to retain the size and
component positions.
A typical use case for ignoring the visibility is here: if the list selection is empty, the details view is made invisible to hide the then obsolete read-only labels. If visibility is honored, the list view would grow and shrink on list selection. If ignored, the layout remains stable.
b
- true
to honor the visibility, i.e. to exclude
invisible components from the sizing and positioning,
false
to ignore the visibility, in other words to
layout visible and invisible componentspublic ListViewBuilder namePrefix(String namePrefix)
namePrefix
- the prefix to be usedpublic ListViewBuilder factory(ComponentFactory factory)
factory
as this builder's new component factory
that is used to create the label or header components.
If not called, the default factory will be used
that can be configured via
FormsSetup.setComponentFactoryDefault(ComponentFactory)
.factory
- the factory to be used to create the header or labelpublic ListViewBuilder label(JComponent labelView)
labelView
- the component that shall label the list view,
often a bound labelpublic ListViewBuilder labelText(String markedText, Object... args)
String.format
with the given arguments.
Equivalent to:
label(aComponentFactory.createLabel(Strings.get(markedText, args)));
markedText
- the label's text, may contain a mnemonic markerargs
- optional format arguments forwarded to String#format
String.format(String, Object...)
public ListViewBuilder headerText(String markedText, Object... args)
String.format
with the given arguments.
Equivalent to:
labelView(aComponentFactory.createHeaderLabel(Strings.get(markedText, args)));
markedText
- the label's text, may contain a mnemonic markerargs
- optional format arguments forwarded to String#format
String.format(String, Object...)
public ListViewBuilder filterView(JComponent filterView)
filterView
- the view to be added.public ListViewBuilder filterViewColumn(String colSpec, Object... args)
"[100dlu, p]"
, which is a column where
the width is determined by the filter view's preferred width,
but a minimum width of 100dlu is ensured. The filter view won't grow
horizontally, if the container gets more space.colSpec
- specifies the horizontal layout of the filter viewargs
- optional colSpec
format arguments
forwarded to String#format
NullPointerException
- if colSpec
is null
public ListViewBuilder listView(JComponent listView)
listView
is a JTable, JList, or JTree, it is
automatically wrapped with a JScrollPane, before the scroll pane
is set as list view.listView
- the component to be used as scrollable list viewNullPointerException
- if listView
is null
public ListViewBuilder listViewRow(String rowSpec, Object... args)
"fill:[100dlu, pref]:grow"
, which is a row
that is filled by the list view; the height is determined
by the list view's preferred height, but a minimum of 100dlu is ensured.
The list view grows vertically, if the container gets more vertical
space.Examples:
.listViewRow("fill:100dlu"); // fixed height .listViewRow("f:100dlu:g"); // fixed start height, grows .listViewRow("f:p"); // no minimum height
rowSpec
- specifies the vertical layout of the list viewargs
- optional rowSpec
format arguments
forwarded to String#format
NullPointerException
- if rowSpec
is null
public ListViewBuilder listBarView(JComponent listBarView)
listBar(JComponent...)
instead.listBarView
- the component to setpublic ListViewBuilder listBar(JComponent... buttons)
Equivalent to listBarView(Forms.buttonBar(buttons))
.
buttons
- the buttons in the list barNullPointerException
- if buttons
is null
IllegalArgumentException
- if no buttons are providedForms.buttonBar(JComponent...)
public ListViewBuilder listStackView(JComponent listStackView)
listStack(JComponent...)
instead.listStackView
- the component to setpublic ListViewBuilder listStack(JComponent... buttons)
Equivalent to listStackView(Forms.buttonStack(buttons))
.
buttons
- the buttons in the list stackNullPointerException
- if buttons
is null
IllegalArgumentException
- if no buttons are providedForms.buttonStack(JComponent...)
public ListViewBuilder listExtrasView(JComponent listExtrasView)
listExtrasView
- the component to setpublic ListViewBuilder detailsView(JComponent detailsView)
detailsView
- the component to setpublic JComponent build()
Copyright © 2002-2015 JGoodies Software GmbH. All Rights Reserved.