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);
| Fields inherited from java.awtComponent |
|---|
| Fields inherited from javax.swingJComponent |
|---|
| Constructor Summary |
|---|
|
Creates a new instance of JXTitledSeparator.
|
|
Creates a new instance of JXTitledSeparator with the specified
title.
|
|
Creates a new instance of JXTitledSeparator with the specified
title and horizontal alignment.
|
|
Creates a new instance of JXTitledSeparator with the specified
title, icon, and horizontal alignment.
|
| Method Summary | |
|---|---|
| int |
Returns the alignment of the title contents along the X axis. |
| int |
Returns the horizontal position of the title's text, relative to the icon. |
| Icon |
Returns the graphic image (glyph, icon) that the JXTitledSeparator displays.
|
| String |
Gets the title. |
| void |
No description provided. |
| void |
No description provided. |
| void |
Sets the alignment of the title along the X axis. |
| void |
Sets the horizontal position of the title's text, relative to the icon. |
| void |
Defines the icon this component will display. |
| void |
Sets the title for the separator. |
| Methods inherited from javax.accessibilityAccessible |
|---|
| Methods inherited from java.awt.imageImageObserver |
|---|
| Methods inherited from javax.swingJPanel |
|---|
| Methods inherited from java.awtMenuContainer |
|---|
| Methods inherited from java.langObject |
|---|
| Methods inherited from javax.swingScrollable |
|---|
public JXTitledSeparator
(
)
JXTitledSeparator with the specified
title. Default horizontal alignment is LEADING, and the default
horizontal text position is TRAILING (title follows icon) JXTitledSeparator with the specified
title and horizontal alignment. The default
horizontal text position is TRAILING (title follows icon) JXTitledSeparator with the specified
title, icon, and horizontal alignment. The default
horizontal text position is TRAILING (title follows icon)
public
int
getHorizontalAlignment
(
)
public
int
getHorizontalTextPosition
(
)
JXTitledSeparator displays.
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.
public
void
setHorizontalTextPosition
(
int
position
)
The default value of this property is null.
JXTitledSeparator. The default title is simply an empty string. Default justification isLEADING, and the default horizontal text position isTRAILING(title follows icon)