org.jdesktop.swingx
Class JXTitledSeparator

public class JXTitledSeparator
extends JXPanel

A simple horizontal separator that contains a title.

JXTitledSeparator allows you to specify the title via the setTitle(String) method. The title alignment may be specified by using the setHorizontalAlignment(int) method, and accepts all the same arguments as the setHorizontalAlignment(int) method.

In addition, you may specify an Icon to use with this separator. The icon will appear "leading" the title (on the left in left-to-right languages, on the right in right-to-left languages). To change the position of the title with respect to the icon, call setHorizontalTextPosition(int) .

The default font and color of the title comes from the LookAndFeel, mimicking the font and color of the TitledBorder

Here are a few example code snippets:


  //create a plain separator
  JXTitledSeparator sep = new JXTitledSeparator();
  sep.setText("Customer Info");

  //create a separator with an icon
  sep = new JXTitledSeparator();
  sep.setText("Customer Info");
  sep.setIcon(new ImageIcon("myimage.png"));

  //create a separator with an icon to the right of the title,
  //center justified
  sep = new JXTitledSeparator();
  sep.setText("Customer Info");
  sep.setIcon(new ImageIcon("myimage.png"));
  sep.setHorizontalAlignment(SwingConstants.CENTER);
  sep.setHorizontalTextPosition(SwingConstants.TRAILING);
 
SinceNot specified.
VersionNot specified.
Authorrbair
Wiki javadoc Use textile entry format.
Add your comments here.
Constructor Summary
JXTitledSeparator()
Creates a new instance of JXTitledSeparator.
JXTitledSeparator( String title )
Creates a new instance of JXTitledSeparator with the specified title.
JXTitledSeparator( String title, int horizontalAlignment )
Creates a new instance of JXTitledSeparator with the specified title and horizontal alignment.
JXTitledSeparator( String title, int horizontalAlignment, Icon icon )
Creates a new instance of JXTitledSeparator with the specified title, icon, and horizontal alignment.
Method Summary
int getHorizontalAlignment()
Returns the alignment of the title contents along the X axis.
int getHorizontalTextPosition()
Returns the horizontal position of the title's text, relative to the icon.
Icon getIcon()
Returns the graphic image (glyph, icon) that the JXTitledSeparator displays.
String getTitle()
Gets the title.
void setFont( Font font )
No description provided.
void setForeground( Color foreground )
No description provided.
void setHorizontalAlignment( int alignment )

Sets the alignment of the title along the X axis.

void setHorizontalTextPosition( int position )
Sets the horizontal position of the title's text, relative to the icon.
void setIcon( Icon icon )
Defines the icon this component will display.
void setTitle( String title )
Sets the title for the separator.
Methods inherited from javax.accessibilityAccessible
Methods inherited from java.awtComponent
Methods inherited from java.awtContainer
Methods inherited from java.awt.imageImageObserver
Methods inherited from javax.swingJComponent
JXTitledSeparator
public JXTitledSeparator ( )
Creates a new instance of JXTitledSeparator. The default title is simply an empty string. Default justification is LEADING, and the default horizontal text position is TRAILING (title follows icon)
Wiki javadoc Use textile entry format.
Add your comments here.
JXTitledSeparator
public JXTitledSeparator ( String title )
Creates a new instance of JXTitledSeparator with the specified title. Default horizontal alignment is LEADING, and the default horizontal text position is TRAILING (title follows icon)
Parameters
TypeNameDescription
String title No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
JXTitledSeparator
public JXTitledSeparator ( String title, int horizontalAlignment )
Creates a new instance of JXTitledSeparator with the specified title and horizontal alignment. The default horizontal text position is TRAILING (title follows icon)
Parameters
TypeNameDescription
String title No description provided.
int horizontalAlignment No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
JXTitledSeparator
public JXTitledSeparator ( String title, int horizontalAlignment, Icon icon )
Creates a new instance of JXTitledSeparator with the specified title, icon, and horizontal alignment. The default horizontal text position is TRAILING (title follows icon)
Parameters
TypeNameDescription
String title No description provided.
int horizontalAlignment No description provided.
Icon icon No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
getHorizontalAlignment
public int getHorizontalAlignment ( )
Returns the alignment of the title contents along the X axis.
Wiki javadoc Use textile entry format.
Add your comments here.
getHorizontalTextPosition
public int getHorizontalTextPosition ( )
Returns the horizontal position of the title's text, relative to the icon.
See also
Wiki javadoc Use textile entry format.
Add your comments here.
getIcon
public Icon getIcon ( )
Returns the graphic image (glyph, icon) that the JXTitledSeparator displays.
See also
Wiki javadoc Use textile entry format.
Add your comments here.
getTitle
public String getTitle ( )
Gets the title.
Wiki javadoc Use textile entry format.
Add your comments here.
setFont
public void setFont ( Font font )
No description provided.
Overrides method in JComponent
Parameters
TypeNameDescription
Font font No description provided.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setForeground
public void setForeground ( Color foreground )
No description provided.
Overrides method in JComponent
Parameters
TypeNameDescription
Color foreground No description provided.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setHorizontalAlignment
public void setHorizontalAlignment ( int alignment )

Sets the alignment of the title along the X axis. If leading, then the title will lead the separator (in left-to-right languages, the title will be to the left and the separator to the right). If centered, then a separator will be to the left, followed by the title (centered), followed by a separator to the right. Trailing will have the title on the right with a separator to its left, in left-to-right languages.

LEFT and RIGHT always position the text left or right of the separator, respectively, regardless of the language orientation.

Parameters
TypeNameDescription
int alignment One of the following constants defined in SwingConstants: LEFT, CENTER, RIGHT, LEADING (the default) or TRAILING.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setHorizontalTextPosition
public void setHorizontalTextPosition ( int position )
Sets the horizontal position of the title's text, relative to the icon.
Parameters
TypeNameDescription
int position One of the following constants defined in SwingConstants: LEFT, CENTER, RIGHT, LEADING, or TRAILING (the default).
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setIcon
public void setIcon ( Icon icon )
Defines the icon this component will display. If the value of icon is null, nothing is displayed.

The default value of this property is null.

Parameters
TypeNameDescription
Icon icon No description provided.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setTitle
public void setTitle ( String title )
Sets the title for the separator. This may be simple html, or plain text.
Parameters
TypeNameDescription
String title the new title. Any string input is acceptable
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.