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);
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 TitledBorderHere are a few example code snippets: