Closed lcy-1024 closed 3 years ago
What exactly doesn't work? It does seem to work correctly for me on v1.2.13.
If you mean that you can't shrink JTabbedPane
within JSplitPane
- this is because WebLaF calculates JTabbedPane
minimum and preferred sizes differently:
MetalLookAndFeel
both sizes in your example are java.awt.Dimension[width=57,height=36]
WebLookAndFeel
both sizes in your example are java.awt.Dimension[width=450,height=38]
This difference is there because WebLaF accounts for tab sizes while MetalLookAndFeel
and probably some other L&Fs don't.
Difference between L&Fs aside - if you want to have any component within either of JSplitPane
sides "shrinkable" - you might want to force at least it's minimum size to either zero or some specific value suitable for you.
On the example you provided:
public static void main ( final String[] args )
{
SwingUtilities.invokeLater ( new Runnable ()
{
@Override
public void run ()
{
WebLookAndFeel.install ();
final JPanel left = new JPanel ();
final JTabbedPane right = new JTabbedPane ( JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT );
for ( int i = 0; i < 10; i++ )
{
right.add ( "Tab " + i, new JPanel () );
}
right.setMinimumSize ( new Dimension ( 50, 50 ) );
final JSplitPane jSplitPane = new JSplitPane ();
jSplitPane.setLeftComponent ( left );
jSplitPane.setRightComponent ( right );
final JFrame jFrame = new JFrame ();
jFrame.add ( jSplitPane );
jFrame.setSize ( 800, 600 );
jFrame.setLocationRelativeTo ( null );
jFrame.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
jFrame.setVisible ( true );
}
} );
}
This way you can shrink the JTabbedPane
area in your example:
thanks,it's worked now
right.setMinimumSize ( new Dimension ( 50, 50 ) );
Since your problem is solved I'll close this issue.
I've created a separate issue #660 for a small enhancement to JTabbedPane
's minimum size.