0

I am trying to use the JXTitledSeparator from SwingX to create a separator with title, like this :

enter image description here

Here is the code i am currently using :

JXTitledSeparator xTitledSeparator1 = new JXTitledSeparator();
xTitledSeparator1.setTitle( "Separator Title" );
xTitledSeparator1.setHorizontalAlignment(0);

But i actually want is to move the separator title "Separator Title" to the left a bit, so it can appear like this:

enter image description here

Is there a way to do that ?

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
Brad
  • 4,457
  • 10
  • 56
  • 93

1 Answers1

0

Try

xTitledSeparator1.setHorizontalAlignment(SwingConstants.LEFT);

or SwingConstants.LEADING. The 0 you are using stands for SwingConstants.CENTER.

If that doesn't work try setHorizontalTextPosition(SwingConstants.LEFT).

Kai
  • 38,985
  • 14
  • 88
  • 103
  • Thanks, but this will move the title to the most left side, and won't do the effect as in the image above. I want the text to be moved a bit. – Brad Apr 23 '13 at 16:36
  • 1
    @Brad In this case I don't see another solution than taking the source of `JXTitledSeparator` and changing the method [`layoutSeparator()`](http://grepcode.com/file/repo1.maven.org/maven2/org.swinglabs.swingx/swingx-core/1.6.5/org/jdesktop/swingx/JXTitledSeparator.java#JXTitledSeparator.layoutSeparator%28%29) – Kai Apr 24 '13 at 11:44
  • Thanks a lot. The solution i chose is using another JSeparator at the left side of the JXTitledSeparator which i use the SwingConstants.LEFT property for it, to give the result in the screenshot above. – Brad Apr 25 '13 at 09:03