tags:

views:

294

answers:

2

Hi

Do somebody knows a (free) horizontal JSeparator with a title label?
Something like that:

--- Title XYZ --------------------

Thank you in advance!
Best Regards
Thomas

+2  A: 

Hmm… without any testing and completely from the top of my head:

JPanel panel = new JPanel();
panel.setBorder(new TitledBorder("Title"));
menu.add(panel);

Most Swing containers eat anything so that might even work.

Another approach would be to create a custom component (maybe with a horizontal BoxLayout) and add a JSeparator, a JLabel, and another JSeparator to it, then add it to the menu.

Bombe
+2  A: 

I found a solution: SwingX JXTitledSeparator. We already use SwingX in our project. I didn't know that SwingX provides a titled separator.

@Bombe Thank you for your help.

Zubi