public final class ListBuilder<T> extends BasicBuilder<T>
Tell the builder the features you'd like the list to have, call build(), and the builder will take care of putting one together for you.
The builder takes care of ensuring that it conforms to UI standards, and does the common work of putting together things like creating a reorderable list, adding the scrollpane, and other commonly configured list settings.
T is the type of item in the list.
Modifier and Type | Class and Description |
---|---|
static class |
ListBuilder.DefaultAction
Built in actions that can be used to quickly create toolbar button actions
|
BasicBuilder.Instructions
instructions
Constructor and Description |
---|
ListBuilder() |
Modifier and Type | Method and Description |
---|---|
BuiltList<T> |
build()
Create and return the final concrete component that can be added to a component hierarchy.
|
protected void |
buildToolbar(BuiltList builtList) |
protected BasicBuilder.Instructions |
createInstructions() |
void |
setActionsDefault(ListBuilder.DefaultAction defaultAction, java.awt.event.ActionListener listener)
Add one of the DefaultActions to the toolbar and listen to it.
|
void |
setEditable(boolean editable, boolean createDefaultButtons)
Allow the items of the list to be edited in place.
|
void |
setHint(java.lang.String hint)
Set a hint that appears below the list
|
void |
setIconFromMethod(java.lang.String methodName)
Supply the name of a method on the type of element contained in the List, this method will be called to get the icon of the displayed element.
This will only be used if a renderer isn't set directly. The method must have no parameters, do not include parenthesis. |
void |
setModel(java.util.List<? extends T> list)
Set the initial contents of the JList from the contents of the given java.util.List.
|
void |
setModel(T[] array)
Set the initial contents of the JList from the contents of the given array.
|
void |
setRenderer(javax.swing.ListCellRenderer renderer)
Set the renderer used by the list.
|
void |
setRenderUsingMethod(java.lang.String methodName)
Uses reflection to render the items in the list, thus avoiding the need to create a specialized renderer
|
void |
setReorderable(boolean reorderable)
Allow the contents of the list to be reordered by the user.
|
void |
setSelectionMode(int selectionMode)
Set the selection mode of the list, by default the mode is single selection
|
void |
setSortable(boolean sortable)
Initially sort the list by using the natural ordering of the items in the list.
|
void |
setSorter(java.util.Comparator<T> comparator)
Initially sort the list by using the ordering of the items determined by the given comparator
Note: only DefaultListModels, SimpleListModels, and models supplied as arrays or lists will obey this ability currently. |
void |
setVisibleRows(int visibleRows)
Set the preferred number of visible rows
|
buildToolbar, setActions, setActionsSecondary, setActionsSecondary, setCheckable, setDoubleClickListener, setEmptyText, setEmptyTextLarge, setLabel, setResizable, setRollover, setSelection, setSelectionEnabledAction, setSelectionEnabledComponent, setTitlebar, setToolbarComponents
protected BasicBuilder.Instructions createInstructions()
createInstructions
in class BasicBuilder<T>
public void setModel(T[] array)
array
- the array to display in the listpublic void setModel(java.util.List<? extends T> list)
list
- the java.util.List to display in the listpublic void setVisibleRows(int visibleRows)
visibleRows
- the number of visible rowspublic void setReorderable(boolean reorderable)
reorderable
-public void setSorter(java.util.Comparator<T> comparator)
comparator
- the object used to determine sort orderpublic void setHint(java.lang.String hint)
hint
-public void setSortable(boolean sortable)
sortable
-public void setEditable(boolean editable, boolean createDefaultButtons)
editable
-createDefaultButtons
- if true create default add and remove toolbar buttons for this list which will add and remove the selected item(s) in the list.public void setRenderer(javax.swing.ListCellRenderer renderer)
renderer
-public void setRenderUsingMethod(java.lang.String methodName)
Uses reflection to render the items in the list, thus avoiding the need to create a specialized renderer
e.g. If the ListBuilder is building a list of Locale objects, calling this method with 'getDisplayLanguage' will display the Locale items as languages.
This will only be used if a renderer isn't set directly.
The method must have no parameters, do not include parenthesis.
methodName
- a method from the type of the ListModel element.public void setActionsDefault(ListBuilder.DefaultAction defaultAction, java.awt.event.ActionListener listener)
defaultAction
-listener
- a listener to be called when the action is performedpublic void setIconFromMethod(java.lang.String methodName)
methodName
- a method from the type of the ListModel element.public void setSelectionMode(int selectionMode)
selectionMode
- a ListSelectionModel constantpublic BuiltList<T> build()
protected void buildToolbar(BuiltList builtList)