JXTitledSeparator extends JXPanel { public void setTitle(String title) { String old = getTitle(); label.setText(title); firePropertyChange("title", old, getTitle()); } JXTitledSeparator();  JXTitledSeparator(String title);  JXTitledSeparator(String title, int horizontalAlignment);  JXTitledSeparator(String title, int horizontalAlignment, Icon icon); void setTitle(String title); String getTitle(); void setHorizontalAlignment(int alignment); int getHorizontalAlignment(); void setHorizontalTextPosition(int position); int getHorizontalTextPosition(); @Override ComponentOrientation getComponentOrientation(); @Override void setComponentOrientation(ComponentOrientation o); void setIcon(Icon icon); Icon getIcon(); @Override void setForeground(Color foreground); @Override void setFont(Font font);  }
@Test public void testPrefSize() { JXTitledSeparator separator = new JXTitledSeparator(); Dimension dim = separator.getPreferredSize(); separator.setTitle("some title definitely longer than empty"); assertTrue(dim.width < separator.getPreferredSize().width); }