T - The type of the underlying Object represented by a Segment.public final class SegmentedControl<T>
extends javax.swing.JPanel
implements java.awt.ItemSelectable
This control is commonly used in toolbars to represent a group of closely related button choices, such as left/center/right text alignment, day/week/year views of a calendar.
By default the SegmentedControl is empty, for it to be usable Segments have to be created and added to it.
| Modifier and Type | Class and Description |
|---|---|
static interface |
SegmentedControl.InfoTipTemplate<T>
Extends oracle.javatools.ui.infotip.templates.Template so that the InfoTip content
gets updated to match the current segment under mouse hover.
|
static class |
SegmentedControl.SelectionType
The selection type used by a SegmentedControl.
|
javax.swing.JPanel.AccessibleJPaneljavax.swing.JComponent.AccessibleJComponentlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW| Constructor and Description |
|---|
SegmentedControl()
Create a SegmentedControl that only allows one segment selected at any one time.
|
SegmentedControl(SegmentedControl.SelectionType selectionType)
Create a SegmentedControl.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addItemListener(java.awt.event.ItemListener itemListener)
Listen for selection changes.
|
void |
addSegment(Segment<T> segment)
Add a segment to the control.
|
void |
addSegment(Segment<T> segment,
int index)
Insert segment at the specified index.
|
java.awt.Dimension |
getMaximumSize() |
java.awt.Dimension |
getMinimumSize() |
java.util.List<SegmentButton<T>> |
getSegmentButtons() |
T |
getSelected()
Get the first selected Segment.
|
Segment<T>[] |
getSelectedObjects() |
SegmentedControl.SelectionType |
getSelectionType() |
SegmentedControlUI |
getUI() |
java.lang.String |
getUIClassID() |
boolean |
hasFocus() |
boolean |
isMaximumSizeSet() |
boolean |
isMinimumSizeSet() |
boolean |
isSelected(Segment<T> segment) |
boolean |
isSelected(T segmentObject) |
void |
removeAllSegments()
Remove all Segments from this control.
|
void |
removeItemListener(java.awt.event.ItemListener itemListener)
Stop listening for selection changes.
|
void |
removeSegment(Segment<T> segment)
Remove the specified segment from this control.
|
void |
setEnabled(boolean enabled)
Enable or disable the whole SegmentedControl.
|
void |
setInfoTip(SegmentedControl.InfoTipTemplate<T> template,
InfoTipStyles style,
oracle.ide.hover.HoverFlavor flavor,
InfoTipOrientation orientation)
Set an InfoTip for the SegmentedControl.
|
void |
setSelected(Segment<T> segment)
Select a Segment.
|
void |
setSelected(T userObject)
Select Segments containing the given object.
|
void |
setUI(javax.swing.plaf.PanelUI ui) |
void |
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, 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, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, 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, validateTreeaction, 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, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, transferFocusUpCyclepublic SegmentedControl()
public SegmentedControl(SegmentedControl.SelectionType selectionType)
selectionType - the selection type for the control.public java.awt.Dimension getMaximumSize()
getMaximumSize in class javax.swing.JComponentpublic java.awt.Dimension getMinimumSize()
getMinimumSize in class javax.swing.JComponentpublic boolean isMinimumSizeSet()
isMinimumSizeSet in class java.awt.Componentpublic boolean isMaximumSizeSet()
isMaximumSizeSet in class java.awt.Componentpublic SegmentedControl.SelectionType getSelectionType()
public void addSegment(Segment<T> segment)
segment - public void addSegment(Segment<T> segment, int index)
segment - the Segment to be addedindex - the position at which to insert the component, or -1 to append the component to the endpublic void setSelected(T userObject)
userObject - Segment.getUserObject()public void addItemListener(java.awt.event.ItemListener itemListener)
addItemListener in interface java.awt.ItemSelectableitemListener - public void removeItemListener(java.awt.event.ItemListener itemListener)
removeItemListener in interface java.awt.ItemSelectableitemListener - public void setUI(javax.swing.plaf.PanelUI ui)
setUI in class javax.swing.JPanelpublic void updateUI()
updateUI in class javax.swing.JPanelpublic SegmentedControlUI getUI()
getUI in class javax.swing.JPanelpublic java.lang.String getUIClassID()
getUIClassID in class javax.swing.JPanelpublic boolean hasFocus()
hasFocus in class java.awt.Componentpublic java.util.List<SegmentButton<T>> getSegmentButtons()
public void removeSegment(Segment<T> segment)
segment - public void removeAllSegments()
public T getSelected()
public Segment<T>[] getSelectedObjects()
getSelectedObjects in interface java.awt.ItemSelectablepublic boolean isSelected(Segment<T> segment)
segment - public boolean isSelected(T segmentObject)
segmentObject - public void setEnabled(boolean enabled)
setEnabled in class javax.swing.JComponentenabled - public void setInfoTip(SegmentedControl.InfoTipTemplate<T> template, InfoTipStyles style, oracle.ide.hover.HoverFlavor flavor, InfoTipOrientation orientation)
template - InfoTipTemplate containing the content to be shown in the InfoTip.