org.jdesktop.swingx.table
Class ColumnControlButton
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.AbstractButton
-
- javax.swing.JButton
-
- org.jdesktop.swingx.table.ColumnControlButton
-
- All Implemented Interfaces:
- java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.SwingConstants
public class ColumnControlButton extends javax.swing.JButtonA component to allow interactive customization ofJXTable's columns. It's main purpose is to allow toggling of table columns' visibility. Additionally, arbitrary configuration actions can be exposed.This component is installed in the
JXTable's trailing corner, if enabled:
From the perspective of atable.setColumnControlVisible(true);JXTable, the component's behaviour is opaque. Typically, the button's action is to popup a component for user interaction.This class is responsible for handling/providing/updating the lists of actions and to keep each Action's state in synch with Table-/Column state. The visible behaviour of the popup is delegated to a
ColumnControlPopup.Default support for adding table (configuration or other)
Actions is informal, driven by convention:- the JXTable's actionMap is scanned for candidate actions, the default marker
is a key of type String which starts with
ColumnControlButton.COLUMN_CONTROL_MARKER - the actions are sorted by that key and then handed over to the ColumnControlPopup for binding and addition of appropriate menu items
- the addition as such is control by additionalActionsVisible property, its default value is true
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description classColumnControlButton.ColumnVisibilityActionA specializedActionwhich takes care of keeping in synch with TableColumn state.classColumnControlButton.DefaultColumnControlPopupA default implementation of ColumnControlPopup.
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.StringCOLUMN_CONTROL_BUTTON_ICON_KEYthe key for looking up the control's icon in the UIManager.static java.lang.StringCOLUMN_CONTROL_BUTTON_MARGIN_KEYthe key for looking up the control's margin in the UIManager.static java.lang.StringCOLUMN_CONTROL_MARKERMarker to auto-recognize actions which should be added to the popup.-
Fields inherited from class javax.swing.AbstractButton
BORDER_PAINTED_CHANGED_PROPERTY, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
-
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
-
-
Constructor Summary
Constructors Constructor and Description ColumnControlButton(JXTable table)Creates a column control button for the table.ColumnControlButton(JXTable table, javax.swing.Icon icon)Creates a column control button for the table.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidapplyComponentOrientation(java.awt.ComponentOrientation o)booleangetAdditionalActionsVisible()Returns the actionsVisible property which controls whether or not additional table Actions should be included into the popup.voidsetActionGrouper(ColumnControlPopup.ActionGrouper grouper)Sets the grouper to use for grouping the additional actions.voidsetAdditionalActionsVisible(boolean additionalActionsVisible)Sets the additonalActionsVisible property.voidtogglePopup()Toggles the popup component's visibility.voidupdateUI()-
Methods inherited from class javax.swing.JButton
getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, removeNotify, setDefaultCapable
-
Methods inherited from class javax.swing.AbstractButton
addActionListener, addChangeListener, addItemListener, doClick, doClick, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHideActionText, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setEnabled, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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, 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
-
-
-
-
Field Detail
-
COLUMN_CONTROL_MARKER
public static final java.lang.String COLUMN_CONTROL_MARKER
Marker to auto-recognize actions which should be added to the popup.- See Also:
- Constant Field Values
-
COLUMN_CONTROL_BUTTON_ICON_KEY
public static final java.lang.String COLUMN_CONTROL_BUTTON_ICON_KEY
the key for looking up the control's icon in the UIManager. Typically, it's LAF dependent.- See Also:
- Constant Field Values
-
COLUMN_CONTROL_BUTTON_MARGIN_KEY
public static final java.lang.String COLUMN_CONTROL_BUTTON_MARGIN_KEY
the key for looking up the control's margin in the UIManager. Typically, it's LAF dependent.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ColumnControlButton
public ColumnControlButton(JXTable table)
Creates a column control button for the table. Uses the default icon as provided by the addon.- Parameters:
table- theJXTablecontrolled by this component
-
ColumnControlButton
public ColumnControlButton(JXTable table, javax.swing.Icon icon)
Creates a column control button for the table. The button uses the given icon and has no text.- Parameters:
table- theJXTablecontrolled by this componenticon- theIconto show
-
-
Method Detail
-
updateUI
public void updateUI()
- Overrides:
updateUIin classjavax.swing.JButton
-
togglePopup
public void togglePopup()
Toggles the popup component's visibility. This method is called by this control's default action.Here: delegates to getControlPopup().
-
getAdditionalActionsVisible
public boolean getAdditionalActionsVisible()
Returns the actionsVisible property which controls whether or not additional table Actions should be included into the popup.- Returns:
- a boolean indicating whether or not additional table Actions are visible
-
setAdditionalActionsVisible
public void setAdditionalActionsVisible(boolean additionalActionsVisible)
Sets the additonalActionsVisible property. It controls whether or not additional table actions should be included into the popup.The default value is
true.- Parameters:
additionalActionsVisible- the additionalActionsVisible to set
-
setActionGrouper
public void setActionGrouper(ColumnControlPopup.ActionGrouper grouper)
Sets the grouper to use for grouping the additional actions. Maybe null to have no additional grouping. Has no effect if the ColumnControlPopup doesn't implement Groupable. The default ColumnControlPopup supports Groupable, but is instantiated without a Grouper.- Parameters:
grouper-
-
applyComponentOrientation
public void applyComponentOrientation(java.awt.ComponentOrientation o)
- Overrides:
applyComponentOrientationin classjava.awt.Container
-
-
DataMelt 3.0 © DataMelt by jWork.ORG