|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.pushingpixels.flamingo.api.common.JCommandButtonPanel
public class JCommandButtonPanel
Panel that hosts command buttons. Provides support for button groups, single selection mode (for toggle command buttons), same icon state / dimension and column-fill / row-fill layout.
Under the default JCommandButtonPanel.LayoutKind.ROW_FILL
, the buttons are laid out in
rows, never exceeding the available horizontal space. A vertical scroll bar
will kick in once there is not enough vertical space to show all the buttons.
The schematic below shows a row-fill command button panel:
+-----------------------------+-+ | | | | +----+ +----+ +----+ +----+ | | | | 01 | | 02 | | 03 | | 04 | | | | +----+ +----+ +----+ +----+ | | | | | | +----+ +----+ +----+ +----+ | | | | 05 | | 06 | | 07 | | 07 | | | | +----+ +----+ +----+ +----+ | | | | | | +----+ +----+ +----+ +----+ | | | | 09 | | 10 | | 11 | | 12 | | | | +----+ +----+ +----+ +----+ | | | | | | +----+ +----+ +----+ +----+ | | | | 13 | | 14 | | 15 | | 16 | | | +-----------------------------+-+
Each row hosts four buttons, and the vertical scroll bar allows scrolling the content down.
Under the JCommandButtonPanel.LayoutKind.COLUMN_FILL
, the buttons are laid out in
columns, never exceeding the available vertical space. A horizontal scroll
bar will kick in once there is not enough horizontal space to show all the
buttons. The schematic below shows a column-fill command button panel:
+---------------------------------+ | | | +----+ +----+ +----+ +----+ +---| | | 01 | | 04 | | 07 | | 10 | | 13| | +----+ +----+ +----+ +----+ +---| | | | +----+ +----+ +----+ +----+ +---| | | 02 | | 05 | | 08 | | 11 | | 14| | +----+ +----+ +----+ +----+ +---| | | | +----+ +----+ +----+ +----+ +---| | | 03 | | 06 | | 09 | | 12 | | 15| | +----+ +----+ +----+ +----+ +---| | | +---------------------------------+ +---------------------------------+
Each column hosts three buttons, and the horizontal scroll bar allows scrolling the content down.
Nested Class Summary | |
---|---|
static class |
JCommandButtonPanel.LayoutKind
Enumerates the available layout kinds. |
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected CommandToggleButtonGroup |
buttonGroup
The button group for the single selection mode. |
protected List<List<AbstractCommandButton>> |
buttons
List of all button groups. |
protected int |
currDimension
Current icon dimension. |
protected CommandButtonDisplayState |
currState
Current icon state. |
protected List<String> |
groupTitles
List of titles for all button groups. |
protected boolean |
isSingleSelectionMode
Indicates the selection mode for the JCommandToggleButton in this
panel. |
protected JCommandButtonPanel.LayoutKind |
layoutKind
Layout kind of this button panel. |
protected int |
maxButtonColumns
Maximum number of columns for this panel. |
protected int |
maxButtonRows
Maximum number of rows for this panel. |
protected boolean |
toShowGroupLabels
If true , the panel will show group labels. |
static String |
uiClassID
|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
protected |
JCommandButtonPanel()
Creates a new panel. |
|
JCommandButtonPanel(CommandButtonDisplayState startingState)
Creates a new panel. |
|
JCommandButtonPanel(int startingDimension)
Creates a new panel. |
Method Summary | |
---|---|
void |
addButtonGroup(String buttonGroupName)
Adds a new button group after all the existing button groups. |
void |
addButtonGroup(String buttonGroupName,
int groupIndex)
Adds a new button group at the specified index. |
int |
addButtonToGroup(String buttonGroupName,
AbstractCommandButton commandButton)
Adds a new button to the specified button group. |
int |
addButtonToGroup(String buttonGroupName,
int indexInGroup,
AbstractCommandButton commandButton)
Adds a new button to the specified button group. |
int |
addButtonToLastGroup(AbstractCommandButton commandButton)
Adds a new button to the specified button group. |
void |
addChangeListener(ChangeListener l)
Adds the specified change listener to this button panel. |
protected void |
fireStateChanged()
Notifies all registered listener that the state of this command button panel has changed. |
int |
getButtonCount()
Returns the number of buttons in this panel. |
List<AbstractCommandButton> |
getGroupButtons(int groupIndex)
Returns the list of all buttons in the specified button group. |
int |
getGroupCount()
Returns the number of button groups in this panel. |
String |
getGroupTitleAt(int index)
Returns the title of the button group at the specified index. |
JCommandButtonPanel.LayoutKind |
getLayoutKind()
Returns the layout kind of this panel. |
int |
getMaxButtonColumns()
Returns the maximum button columns for this panel. |
int |
getMaxButtonRows()
Returns the maximum button rows for this panel. |
Dimension |
getPreferredScrollableViewportSize()
|
int |
getScrollableBlockIncrement(Rectangle visibleRect,
int orientation,
int direction)
|
boolean |
getScrollableTracksViewportHeight()
|
boolean |
getScrollableTracksViewportWidth()
|
int |
getScrollableUnitIncrement(Rectangle visibleRect,
int orientation,
int direction)
|
JCommandToggleButton |
getSelectedButton()
Returns the selected button of this panel. |
String |
getUIClassID()
|
boolean |
isToShowGroupLabels()
Returns indication whether button group labels should be shown. |
void |
removeAllGroups()
Removes all the button groups and buttons from this panel. |
void |
removeButtonFromGroup(String buttonGroupName,
int indexInGroup)
Removes the button at the specified index from the specified button group. |
void |
removeButtonGroup(String buttonGroupName)
Removes the specified button group. |
void |
removeChangeListener(ChangeListener l)
Removes the specified change listener from this button panel. |
void |
setIconDimension(int dimension)
Sets the new dimension for the icons in this panel. |
void |
setIconState(CommandButtonDisplayState state)
Sets the new state for the icons in this panel. |
void |
setLayoutKind(JCommandButtonPanel.LayoutKind layoutKind)
Sets the new layout kind for this panel. |
void |
setMaxButtonColumns(int maxButtonColumns)
Sets the maximum button columns for this panel. |
void |
setMaxButtonRows(int maxButtonRows)
Sets the maximum button rows for this panel. |
void |
setSingleSelectionMode(boolean isSingleSelectionMode)
Sets the selection mode for this panel. |
void |
setToShowGroupLabels(boolean toShowGroupLabels)
Sets indication whether button group labels should be shown. |
void |
updateUI()
|
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, paramString, setUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String uiClassID
getUIClassID()
,
Constant Field Valuesprotected List<String> groupTitles
getGroupCount()
,
getGroupTitleAt(int)
protected List<List<AbstractCommandButton>> buttons
getGroupCount()
,
getGroupButtons(int)
protected int maxButtonColumns
JCommandButtonPanel.LayoutKind.ROW_FILL
.
getMaxButtonColumns()
,
setMaxButtonColumns(int)
protected int maxButtonRows
JCommandButtonPanel.LayoutKind.COLUMN_FILL
.
getMaxButtonRows()
,
setMaxButtonRows(int)
protected boolean isSingleSelectionMode
JCommandToggleButton
in this
panel.
setSingleSelectionMode(boolean)
protected boolean toShowGroupLabels
true
, the panel will show group labels.
setToShowGroupLabels(boolean)
,
isToShowGroupLabels()
protected CommandToggleButtonGroup buttonGroup
protected int currDimension
protected CommandButtonDisplayState currState
protected JCommandButtonPanel.LayoutKind layoutKind
getLayoutKind()
,
setLayoutKind(LayoutKind)
Constructor Detail |
---|
protected JCommandButtonPanel()
public JCommandButtonPanel(int startingDimension)
startingDimension
- Initial dimension for buttons.public JCommandButtonPanel(CommandButtonDisplayState startingState)
startingState
- Initial state for buttons.Method Detail |
---|
public void addButtonGroup(String buttonGroupName, int groupIndex)
buttonGroupName
- Button group name.groupIndex
- Button group index.addButtonGroup(String)
,
removeButtonGroup(String)
,
removeAllGroups()
public void addButtonGroup(String buttonGroupName)
buttonGroupName
- Button group name.addButtonGroup(String, int)
,
removeButtonGroup(String)
,
removeAllGroups()
public void removeButtonGroup(String buttonGroupName)
buttonGroupName
- Name of the button group to remove.addButtonGroup(String)
,
addButtonGroup(String, int)
,
removeAllGroups()
public int addButtonToLastGroup(AbstractCommandButton commandButton)
commandButton
- Button to add.
addButtonToGroup(String, AbstractCommandButton)
,
addButtonToGroup(String, int, AbstractCommandButton)
,
removeButtonFromGroup(String, int)
public int addButtonToGroup(String buttonGroupName, AbstractCommandButton commandButton)
buttonGroupName
- Name of the button group.commandButton
- Button to add.
addButtonToGroup(String, int, AbstractCommandButton)
,
addButtonToLastGroup(AbstractCommandButton)
,
removeButtonFromGroup(String, int)
public int addButtonToGroup(String buttonGroupName, int indexInGroup, AbstractCommandButton commandButton)
buttonGroupName
- Name of the button group.indexInGroup
- Index of the button in group.commandButton
- Button to add.
addButtonToGroup(String, int, AbstractCommandButton)
,
addButtonToLastGroup(AbstractCommandButton)
,
removeButtonFromGroup(String, int)
public void removeButtonFromGroup(String buttonGroupName, int indexInGroup)
buttonGroupName
- Name of the button group.indexInGroup
- Index of the button to remove.addButtonToGroup(String, AbstractCommandButton)
,
addButtonToGroup(String, int, AbstractCommandButton)
,
addButtonToLastGroup(AbstractCommandButton)
public void removeAllGroups()
addButtonGroup(String, int)
,
addButtonGroup(String)
,
removeButtonGroup(String)
,
removeButtonFromGroup(String, int)
public int getGroupCount()
public int getButtonCount()
public String getGroupTitleAt(int index)
index
- Button group index.
public void updateUI()
updateUI
in class JPanel
public String getUIClassID()
getUIClassID
in class JPanel
public void setMaxButtonColumns(int maxButtonColumns)
JCommandButtonPanel.LayoutKind.ROW_FILL
, it will have no more
than this number of buttons in each row. Fires a
maxButtonColumns
property change event.
maxButtonColumns
- Maximum button columns for this panel.getMaxButtonColumns()
,
setMaxButtonRows(int)
public int getMaxButtonColumns()
JCommandButtonPanel.LayoutKind.ROW_FILL
.
setMaxButtonColumns(int)
,
getMaxButtonRows()
public void setMaxButtonRows(int maxButtonRows)
JCommandButtonPanel.LayoutKind.COLUMN_FILL
, it will have no more
than this number of buttons in each column. Fires a
maxButtonRows
property change event.
maxButtonRows
- Maximum button rows for this panel.getMaxButtonRows()
,
setMaxButtonColumns(int)
public int getMaxButtonRows()
JCommandButtonPanel.LayoutKind.COLUMN_FILL
.
setMaxButtonRows(int)
,
getMaxButtonColumns()
public List<AbstractCommandButton> getGroupButtons(int groupIndex)
groupIndex
- Group index.
getGroupCount()
public void setSingleSelectionMode(boolean isSingleSelectionMode)
true
is passed as
the parameter, all JCommandToggleButton
in this panel are set to
belong to the same button group.
isSingleSelectionMode
- If true
,all JCommandToggleButton
in this
panel are set to belong to the same button group.getSelectedButton()
public void setToShowGroupLabels(boolean toShowGroupLabels)
toShowGroupLabels
property change event.
toShowGroupLabels
- If true
, this panel will show the labels of the
button groups.isToShowGroupLabels()
public boolean isToShowGroupLabels()
true
, this panel shows the labels of the button
groups, and false
otherwise.setToShowGroupLabels(boolean)
public void setIconDimension(int dimension)
CommandButtonDisplayState.FIT_TO_ICON
.
dimension
- New dimension for the icons in this panel.setIconState(CommandButtonDisplayState)
public void setIconState(CommandButtonDisplayState state)
CommandButtonDisplayState.BIG
,
CommandButtonDisplayState.TILE
,
CommandButtonDisplayState.MEDIUM
and
CommandButtonDisplayState.SMALL
).
state
- New state for the icons in this panel.setIconDimension(int)
public JCommandToggleButton getSelectedButton()
setSingleSelectionMode(boolean)
),
returning null
otherwise.
setSingleSelectionMode(boolean)
public JCommandButtonPanel.LayoutKind getLayoutKind()
setLayoutKind(LayoutKind)
public void setLayoutKind(JCommandButtonPanel.LayoutKind layoutKind)
layoutKind
property change event.
layoutKind
- New layout kind for this panel.getLayoutKind()
public void addChangeListener(ChangeListener l)
l
- Change listener to add.removeChangeListener(ChangeListener)
public void removeChangeListener(ChangeListener l)
l
- Change listener to remove.addChangeListener(ChangeListener)
protected void fireStateChanged()
public Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize
in interface Scrollable
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
getScrollableBlockIncrement
in interface Scrollable
public boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight
in interface Scrollable
public boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth
in interface Scrollable
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement
in interface Scrollable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |