public final class TableToolbar
extends javax.swing.JPanel
These buttons can be made visible either by setting setToolMask or calling setXXXVisible method. Then you can set the default action for these buttons using setDefaultXXXAction. If the action button supports more than one action, you can assign the additional actions using setXXXMenuActions. These actions will appear in the dropdown menu of the tool button.
By default we have implemented various actions that can be assigned to the above mentioned standard tools. You can get these default actions using various ToolAction. Clients should either use DefaultTableModel or EditableTableModel to get automatic support for these actions.
Clients can also add custom components or actions using addActionControl method.
Modifier and Type | Class and Description |
---|---|
static class |
TableToolbar.ToolAction
Action Keys to get some of the default action for the table
|
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static int |
TOOL_CLEAR
Constant indicating Clear button in Toolbar
|
static int |
TOOL_COPY
Constant indicating Copy button in Toolbar
|
static int |
TOOL_DELETE
Constant indicating Delete button in Toolbar
|
static int |
TOOL_DUPLICATE
Constant indicating Duplicate button in Toolbar
|
static int |
TOOL_EDIT
Constant indicating Edit button in Toolbar
|
static int |
TOOL_NEW
Constant indicating New/Add button in Toolbar
|
static int |
TOOL_NONE
Constant indicating no buttons in Toolbar
|
static int |
TOOL_PASTE
Constant indicating Paste button in Toolbar
|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
TableToolbar(javax.swing.JTable table)
Create a TitleToolbar component for the specified table.
|
TableToolbar(javax.swing.JTable table,
java.lang.String label)
Create a TitleToolbar component for the specified table which shows the
header label.
|
TableToolbar(javax.swing.JTable table,
java.lang.String label,
int toolMask)
Create a TitleToolbar component for the specified table which shows the
header label and the tool buttons specified in the toolMask.
|
Modifier and Type | Method and Description |
---|---|
void |
addActionControl(javax.swing.Action action)
Add a custom tool component to the table toolbar at the right side.
|
void |
addActionControl(javax.swing.Action action,
boolean right)
Add a custom tool component to the table toolbar.
|
void |
addActionControl(java.awt.Component tool)
Add a custom tool component to the table toolbar at the right side.
|
void |
addActionControl(java.awt.Component tool,
boolean right)
Add a custom tool component to the table toolbar.
|
javax.swing.Action[] |
getAddMenuActions()
Returns the menu actions of Add button.
|
javax.swing.Action[] |
getClearMenuActions()
Returns the menu actions of clear button.
|
javax.swing.Action[] |
getCopyMenuActions()
Returns the menu actions of copy button.
|
javax.swing.Action |
getDefaultAction(TableToolbar.ToolAction action)
Gets one of those default actions mentioned in ToolAction.* for this table.
|
javax.swing.Action |
getDefaultAddAction()
Default action for Add button
|
javax.swing.Action |
getDefaultClearAction()
Default action for Clear button
|
javax.swing.Action |
getDefaultCopyAction()
Default action for Copy button
|
javax.swing.Action |
getDefaultDeleteAction()
Default action for Delete button
|
javax.swing.Action |
getDefaultDuplicateAction()
Default action for duplicate button
|
javax.swing.Action |
getDefaultEditAction()
Default action for Edit button
|
javax.swing.Action |
getDefaultPasteAction()
Default action for Paste button
|
javax.swing.Action[] |
getDeleteMenuActions()
Returns the menu actions of delete button.
|
javax.swing.Action[] |
getDuplicateMenuActions()
Returns the menu actions of duplicate button.
|
javax.swing.Action[] |
getEditMenuActions()
Returns the menu actions of edit button.
|
java.lang.String |
getLabel()
Returns the title header label.
|
javax.swing.Action[] |
getPasteMenuActions()
Returns the menu actions of paste button.
|
int |
getToolMask()
The buttonMask, a bitwise or of the Tool_* constants.
|
boolean |
isAddEnabled()
Returns whether the add button is enabled or not.
|
boolean |
isAddVisible()
Returns whether the add button is added and visible in the toolbar.
|
boolean |
isClearEnabled()
Returns whether the clear button is enabled or not.
|
boolean |
isClearVisible()
Returns whether the clear button is added and visible in the toolbar.
|
boolean |
isCopyEnabled()
Returns whether the copy button is enabled or not.
|
boolean |
isCopyVisible()
Returns whether the copy button is added and visible in the toolbar.
|
boolean |
isDeleteEnabled()
Returns whether the delete button is enabled or not.
|
boolean |
isDeleteVisible()
Returns whether the delete button is added and visible in the toolbar.
|
boolean |
isDuplicateEnabled()
Returns whether the duplicate button is enabled or not.
|
boolean |
isDuplicateVisible()
Returns whether the duplicate button is added and visible in the toolbar.
|
boolean |
isEditEnabled()
Returns whether the edit button is enabled or not.
|
boolean |
isEditVisible()
Returns whether the edit button is added and visible in the toolbar.
|
boolean |
isPasteEnabled()
Returns whether the paste button is enabled or not.
|
boolean |
isPasteVisible()
Returns whether the paste button is added and visible in the toolbar.
|
void |
removeActionControl(java.awt.Component tool)
Remove the custom tool component you added to this toolbar.
|
void |
setAddEnabled(boolean enable)
Enable/Disable the new/add button.
|
void |
setAddMenuActions(javax.swing.Action... addAction)
Sets the menu actions for Add button.
|
void |
setAddVisible(boolean visible)
Add the Add/New button to the toolbar.
|
void |
setClearEnabled(boolean enable)
Enable/Disable the clear button.
|
void |
setClearMenuActions(javax.swing.Action... copyAction)
Sets the menu actions for clear button.
|
void |
setClearVisible(boolean visible)
Add the Clear button to the toolbar.
|
void |
setCopyEnabled(boolean enable)
Enable/Disable the copy button.
|
void |
setCopyMenuActions(javax.swing.Action... copyAction)
Sets the menu actions for copy button.
|
void |
setCopyVisible(boolean visible)
Add the Copy button to the toolbar.
|
void |
setDefaultAddAction(javax.swing.Action action)
Default action for Add button
|
void |
setDefaultClearAction(javax.swing.Action action)
Default action for Clear button
|
void |
setDefaultCopyAction(javax.swing.Action action)
Default action for Copy button
|
void |
setDefaultDeleteAction(javax.swing.Action action)
Default action for Delete button
|
void |
setDefaultDuplicateAction(javax.swing.Action action)
Default action for duplicate button
|
void |
setDefaultEditAction(javax.swing.Action action)
Default action for Edit button
|
void |
setDefaultPasteAction(javax.swing.Action action)
Default action for Paste button
|
void |
setDeleteEnabled(boolean enable)
Enable/Disable the delete button.
|
void |
setDeleteMenuActions(javax.swing.Action... copyAction)
Sets the menu actions for delete button.
|
void |
setDeleteVisible(boolean visible)
Add the Delete button to the toolbar.
|
void |
setDuplicateEnabled(boolean enable)
Enable/Disable the duplicate button.
|
void |
setDuplicateMenuActions(javax.swing.Action... copyAction)
Sets the menu actions for duplicate button.
|
void |
setDuplicateVisible(boolean visible)
Add the Duplicate button to the toolbar.
|
void |
setEditEnabled(boolean enable)
Enable/Disable the edit button.
|
void |
setEditMenuActions(javax.swing.Action... editAction)
Sets the menu action for Edit button.
|
void |
setEditVisible(boolean visible)
Add the Edit button to the toolbar.
|
void |
setLabel(java.lang.String text)
Set the title header label.
|
void |
setPasteEnabled(boolean enable)
Enable/Disable the paste button.
|
void |
setPasteMenuActions(javax.swing.Action... copyAction)
Sets the menu actions for paste button.
|
void |
setPasteVisible(boolean visible)
Add the Paste button to the toolbar.
|
void |
setStatusIndicator(StatusIndicator statusIndicator)
set the status indicator for the table (or pass null to not show status).
|
void |
setToolMask(int mask)
Choose which tool buttons to add to this toolbar.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final int TOOL_NONE
public static final int TOOL_NEW
public static final int TOOL_EDIT
public static final int TOOL_DELETE
public static final int TOOL_CLEAR
public static final int TOOL_COPY
public static final int TOOL_PASTE
public static final int TOOL_DUPLICATE
public TableToolbar(javax.swing.JTable table)
public TableToolbar(javax.swing.JTable table, java.lang.String label)
public TableToolbar(javax.swing.JTable table, java.lang.String label, int toolMask)
public void setLabel(java.lang.String text)
public java.lang.String getLabel()
public void setStatusIndicator(StatusIndicator statusIndicator)
statusIndicator
- public void setToolMask(int mask)
public int getToolMask()
public void setAddVisible(boolean visible)
public boolean isAddVisible()
public void setAddEnabled(boolean enable)
public boolean isAddEnabled()
public void setAddMenuActions(javax.swing.Action... addAction)
public javax.swing.Action[] getAddMenuActions()
public void setDefaultAddAction(javax.swing.Action action)
public javax.swing.Action getDefaultAddAction()
public void setEditVisible(boolean visible)
public boolean isEditVisible()
public void setEditEnabled(boolean enable)
public boolean isEditEnabled()
public void setEditMenuActions(javax.swing.Action... editAction)
public javax.swing.Action[] getEditMenuActions()
public void setDefaultEditAction(javax.swing.Action action)
public javax.swing.Action getDefaultEditAction()
public void setDeleteVisible(boolean visible)
public boolean isDeleteVisible()
public void setDeleteEnabled(boolean enable)
public boolean isDeleteEnabled()
public void setDeleteMenuActions(javax.swing.Action... copyAction)
public javax.swing.Action[] getDeleteMenuActions()
public void setDefaultDeleteAction(javax.swing.Action action)
public javax.swing.Action getDefaultDeleteAction()
public void setClearVisible(boolean visible)
public boolean isClearVisible()
public void setClearEnabled(boolean enable)
public boolean isClearEnabled()
public void setClearMenuActions(javax.swing.Action... copyAction)
public javax.swing.Action[] getClearMenuActions()
public void setDefaultClearAction(javax.swing.Action action)
public javax.swing.Action getDefaultClearAction()
public void setCopyVisible(boolean visible)
public boolean isCopyVisible()
public void setCopyEnabled(boolean enable)
public boolean isCopyEnabled()
public void setCopyMenuActions(javax.swing.Action... copyAction)
public javax.swing.Action[] getCopyMenuActions()
public void setDefaultCopyAction(javax.swing.Action action)
public javax.swing.Action getDefaultCopyAction()
public void setPasteVisible(boolean visible)
public boolean isPasteVisible()
public void setPasteEnabled(boolean enable)
public boolean isPasteEnabled()
public void setPasteMenuActions(javax.swing.Action... copyAction)
public javax.swing.Action[] getPasteMenuActions()
public void setDefaultPasteAction(javax.swing.Action action)
public javax.swing.Action getDefaultPasteAction()
public void setDuplicateVisible(boolean visible)
public boolean isDuplicateVisible()
public void setDuplicateEnabled(boolean enable)
public boolean isDuplicateEnabled()
public void setDuplicateMenuActions(javax.swing.Action... copyAction)
public javax.swing.Action[] getDuplicateMenuActions()
public void setDefaultDuplicateAction(javax.swing.Action action)
public javax.swing.Action getDefaultDuplicateAction()
public void addActionControl(javax.swing.Action action)
public void addActionControl(javax.swing.Action action, boolean right)
public void addActionControl(java.awt.Component tool)
public void addActionControl(java.awt.Component tool, boolean right)
public void removeActionControl(java.awt.Component tool)
public javax.swing.Action getDefaultAction(TableToolbar.ToolAction action)