Package com.jidesoft.swing
Class TitledSeparator
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- com.jidesoft.swing.TitledSeparator
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
public class TitledSeparator extends javax.swing.JPanel
TitledSeparator
is a component used for separating components on a panel or in a GUI. EachTitledSeparator
is comprised of a title part and a graphical line. This component is preferred overTitledBorder
when no full border is desired. To see this component in action, please refer to the TitledSeparator Demo. Usage This class presents a large number of constructors. As such, configurating theTitledSeparator
can be wholly achieved at construction time. The list below shows the available constructors for this.
Alternatively, you may use the empty constructor. When this approach is used, the text, border, text alignment and border alignment will need to be explicitly set. For example:-TitledSeparator(String text) TitledSeparator(String text, int textAlignment) TitledSeparator(String text, int type, int textAlignment) TitledSeparator(JComponent component, int textAlignment) TitledSeparator(JComponent component, int type, int textAlignment) TitledSeparator(JComponent component, Border border, int alignment) TitledSeparator(JComponent component, int type, int textAlignment, int barAlignment) TitledSeparator(JComponent component, Border border, int textAlignment, int barAlignment)
TitledSeparator separator = new TitledSeparator(); separator.setLabelComponent(new JLabel("Configured TitledSeparator")); separator.setTextAlignment(right); separator.setBarAlignment(center); separator.setSeparatorBorder(new PartialEtchedBorder(PartialSide.SOUTH));
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PROPERTY_BAR_ALIGNMENT
Identifies a change in the bar alignment.static java.lang.String
PROPERTY_LABEL
Identifies the label has changed.static java.lang.String
PROPERTY_SEPARATOR_BORDER
Identifies the border has changed.static java.lang.String
PROPERTY_TEXT_ALIGNMENT
Identifies a change in the text alignment.static int
TYPE_PARTIAL_ETCHED
This value indicates an etched styled line separator.static int
TYPE_PARTIAL_GRADIENT_LINE
This value indicates a gradient line will be used for the separator.static int
TYPE_PARTIAL_LINE
This value indicates a solid line styled separator.-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description TitledSeparator()
Creates the default titled separator.TitledSeparator(java.lang.String text)
Creates a default titled separator with the specified text.TitledSeparator(java.lang.String text, int textAlignment)
Creates a titled separator with the specified text and alignment.TitledSeparator(java.lang.String text, int type, int textAlignment)
Creates a titled separator with the specified text, border type and alignment.TitledSeparator(javax.swing.JComponent labelComponent, int textAlignment)
Creates a titled separator with the specified component and alignment.TitledSeparator(javax.swing.JComponent labelComponent, int type, int textAlignment)
Creates a titled separator with the specified component, border type and alignment.TitledSeparator(javax.swing.JComponent labelComponent, int type, int textAlignment, int barAlignment)
Creates a titled separator with the specified component, border type, alignment and vertical alignment.TitledSeparator(javax.swing.JComponent labelComponent, javax.swing.border.Border border, int textAlignment)
Creates a titled separator with the specified component, border and alignment.TitledSeparator(javax.swing.JComponent labelComponent, javax.swing.border.Border border, int textAlignment, int barAlignment)
Creates a titled separator with the specified component, border, alignment and vertical alignment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getBarAlignment()
Returns the bars vertical alignment.javax.swing.JComponent
getLabelComponent()
Returns the label part of this Titled Separator.javax.swing.border.Border
getSeparatorBorder()
Returns the border type.int
getTextAlignment()
Returns the texts horizontal alignment.void
setBarAlignment(int barAlignment)
Sets the bars vertical alignment.void
setLabelComponent(javax.swing.JComponent labelComponent)
Sets the labelComponent part of this Titled Separator.void
setSeparatorBorder(javax.swing.border.Border border)
Sets the border to be used as the graphical line region of this Titled Separator.void
setTextAlignment(int textAlignment)
Sets the texts horizontal alignment.void
validateTitledSeparator()
Responsible for configurating thisTitledSeparator
.
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
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
-
Methods inherited from class java.awt.Container
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
-
Methods inherited from class java.awt.Component
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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
TYPE_PARTIAL_ETCHED
public static final int TYPE_PARTIAL_ETCHED
This value indicates an etched styled line separator.- See Also:
- Constant Field Values
-
TYPE_PARTIAL_LINE
public static final int TYPE_PARTIAL_LINE
This value indicates a solid line styled separator.- See Also:
- Constant Field Values
-
TYPE_PARTIAL_GRADIENT_LINE
public static final int TYPE_PARTIAL_GRADIENT_LINE
This value indicates a gradient line will be used for the separator.- See Also:
- Constant Field Values
-
PROPERTY_LABEL
public static final java.lang.String PROPERTY_LABEL
Identifies the label has changed.
-
PROPERTY_SEPARATOR_BORDER
public static final java.lang.String PROPERTY_SEPARATOR_BORDER
Identifies the border has changed.
-
PROPERTY_BAR_ALIGNMENT
public static final java.lang.String PROPERTY_BAR_ALIGNMENT
Identifies a change in the bar alignment.- See Also:
setBarAlignment(int)
, Constant Field Values
-
PROPERTY_TEXT_ALIGNMENT
public static final java.lang.String PROPERTY_TEXT_ALIGNMENT
Identifies a change in the text alignment.- See Also:
setTextAlignment(int)
, Constant Field Values
-
-
Constructor Detail
-
TitledSeparator
public TitledSeparator()
Creates the default titled separator.
-
TitledSeparator
public TitledSeparator(java.lang.String text)
Creates a default titled separator with the specified text.- Parameters:
text
- the title of this titled separator
-
TitledSeparator
public TitledSeparator(java.lang.String text, int textAlignment)
Creates a titled separator with the specified text and alignment. The alignment determines whether the text will lye on the right or left of the separator line.- Parameters:
text
- the title of this titled separatortextAlignment
- Valid values are: SwingConstants.LEFT, SwingConstants.RIGHT, SwingConstants.LEADING or SwingConstants.TRAILING.
-
TitledSeparator
public TitledSeparator(java.lang.String text, int type, int textAlignment)
Creates a titled separator with the specified text, border type and alignment. The alignment determines whether the text will lye on the right or left of the separator line.- Parameters:
text
- the title of this titled separatortype
- the style of border used as the separator line. Valid values are:- TitledSeparator.TYPE_PARTIAL_ETCHED, TitledSeparator.TYPE_PARTIAL_LINE or TitledSeparator.TYPE_PARTIAL_GRADIENT_LINE.textAlignment
- Valid values are: SwingConstants.LEFT, SwingConstants.RIGHT, SwingConstants.LEADING or SwingConstants.TRAILING.
-
TitledSeparator
public TitledSeparator(javax.swing.JComponent labelComponent, int textAlignment)
Creates a titled separator with the specified component and alignment. The alignment determines whether the specified component will lye on the right or left of the separator line.- Parameters:
labelComponent
- the component to be used as the titled part of this separatortextAlignment
- Valid values are: SwingConstants.LEFT, SwingConstants.RIGHT, SwingConstants.LEADING or SwingConstants.TRAILING.
-
TitledSeparator
public TitledSeparator(javax.swing.JComponent labelComponent, int type, int textAlignment)
Creates a titled separator with the specified component, border type and alignment. The alignment determines whether the specified component will lye on the right or left of the separator line.- Parameters:
labelComponent
- the component to be used as the titled part of this separatortype
- the style of border used as the separator line. Valid values are:- TitledSeparator.TYPE_PARTIAL_ETCHED, TitledSeparator.TYPE_PARTIAL_LINE or TitledSeparator.TYPE_PARTIAL_GRADIENT_LINE.textAlignment
- Valid values are: SwingConstants.LEFT, SwingConstants.RIGHT, SwingConstants.LEADING or SwingConstants.TRAILING.
-
TitledSeparator
public TitledSeparator(javax.swing.JComponent labelComponent, javax.swing.border.Border border, int textAlignment)
Creates a titled separator with the specified component, border and alignment. The alignment determines whether the specified component will lye on the right or left of the separator line.- Parameters:
labelComponent
- the component to be used as the titled part of this separatorborder
- the border to be used as the separator linetextAlignment
- Valid values are: SwingConstants.LEFT, SwingConstants.RIGHT, SwingConstants.LEADING or SwingConstants.TRAILING.
-
TitledSeparator
public TitledSeparator(javax.swing.JComponent labelComponent, int type, int textAlignment, int barAlignment)
Creates a titled separator with the specified component, border type, alignment and vertical alignment. The alignment determines whether the specified component will lye on the right or left of the separator line. The vertical alignment refers to the alignment of the separator line -- top, middle or bottom. Whenspecifyingg a border, the border is set with default values, for example: bothTYPE_PARTIAL_LINE
andTYPE_PARTIAL_LINE
are configured with a 'thickness' of one pixel. If the the border required is not the default version, please use another constructor: TitledSeparator(component, border, alignment, verticalAlignment).- Parameters:
labelComponent
- the component to be used as the titled part of this separatortype
- the style of border used as the separator line. Valid values are:- TitledSeparator.TYPE_PARTIAL_ETCHED, TitledSeparator.TYPE_PARTIAL_LINE or TitledSeparator.TYPE_PARTIAL_GRADIENT_LINE.textAlignment
- Valid values are: SwingConstants.LEFT, SwingConstants.RIGHT, SwingConstants.LEADING or SwingConstants.TRAILING.barAlignment
- Valid values are: SwingConstants.TOP, SwingConstants.CENTER or SwingConstants.BOTTOM.
-
TitledSeparator
public TitledSeparator(javax.swing.JComponent labelComponent, javax.swing.border.Border border, int textAlignment, int barAlignment)
Creates a titled separator with the specified component, border, alignment and vertical alignment. The alignment determines whether the specified component will lye on the right or left of the separator line. The vertical alignment refers to the alignment of the separator line -- top, middle or bottom.- Parameters:
labelComponent
- the component to be used as the titled part of this separatorborder
- the border to be used as the separator linetextAlignment
- Valid values are: SwingConstants.LEFT, SwingConstants.RIGHT, SwingConstants.LEADING or SwingConstants.TRAILING.barAlignment
- Valid values are: SwingConstants.TOP, SwingConstants.CENTER or SwingConstants.BOTTOM.
-
-
Method Detail
-
setLabelComponent
public void setLabelComponent(javax.swing.JComponent labelComponent)
Sets the labelComponent part of this Titled Separator.- Parameters:
labelComponent
- the component holding the text to display as the title.- See Also:
getLabelComponent()
-
getLabelComponent
public javax.swing.JComponent getLabelComponent()
Returns the label part of this Titled Separator.- Returns:
- the component holding the text to display as the title.
-
setSeparatorBorder
public void setSeparatorBorder(javax.swing.border.Border border)
Sets the border to be used as the graphical line region of this Titled Separator.- Parameters:
border
- Any border of type: com.jidesoft.swing.PartialEtchedBorder, com.jidesoft.swing.PartialLineBorder or com.jidesoft.swing.PartialGradientLineBorder.- See Also:
getSeparatorBorder()
-
getSeparatorBorder
public javax.swing.border.Border getSeparatorBorder()
Returns the border type.- Returns:
- the border type. Valid return values are: TitledSeparator.TYPE_PARTIAL_ETCHED, TitledSeparator.TYPE_PARTIAL_LINE, TitledSeparator.TYPE_PARTIAL_GRADIENT_LINE or -1 if the current border is none of the above.
-
setTextAlignment
public void setTextAlignment(int textAlignment)
Sets the texts horizontal alignment.- Parameters:
textAlignment
- an int representing the texts horizontal position. Valid values are: SwingConstants.LEFT, SwingConstants.RIGHT, SwingConstants.LEADING or SwingConstants.TRAILING.- See Also:
getTextAlignment()
-
getTextAlignment
public int getTextAlignment()
Returns the texts horizontal alignment.- Returns:
- the texts horizontal alignment. Valid return values are: SwingConstants.LEFT, SwingConstants.RIGHT, or SwingConstants.CENTER.
-
setBarAlignment
public void setBarAlignment(int barAlignment)
Sets the bars vertical alignment.- Parameters:
barAlignment
- Valid values are: SwingConstants.TOP, SwingConstants.CENTER or SwingConstants.BOTTOM.- See Also:
getBarAlignment()
-
getBarAlignment
public int getBarAlignment()
Returns the bars vertical alignment.- Returns:
- the barsverticall alignment. Valid values are: SwingConstants.TOP, SwingConstants.CENTER or SwingConstants.BOTTOM.
-
validateTitledSeparator
public void validateTitledSeparator()
Responsible for configurating thisTitledSeparator
. This is the method through which all constructors ultimately feed.
-
-