3434import javax .swing .plaf .ComponentUI ;
3535import javax .swing .plaf .basic .BasicSplitPaneDivider ;
3636import javax .swing .plaf .basic .BasicSplitPaneUI ;
37+ import com .formdev .flatlaf .FlatClientProperties ;
3738import com .formdev .flatlaf .ui .FlatStylingSupport .Styleable ;
3839import com .formdev .flatlaf .ui .FlatStylingSupport .StyleableUI ;
3940import com .formdev .flatlaf .ui .FlatStylingSupport .UnknownStyleException ;
@@ -352,7 +353,7 @@ public void layoutContainer( Container c ) {
352353 if ( leftButton == null || rightButton == null || !splitPane .isOneTouchExpandable () )
353354 return ;
354355
355- // increase side of buttons, which makes them easier to hit by the user
356+ // increase size of buttons, which makes them easier to hit by the user
356357 // and avoids cut arrows at small divider sizes
357358 int extraSize = UIScale .scale ( 4 );
358359 if ( orientation == JSplitPane .VERTICAL_SPLIT ) {
@@ -367,10 +368,19 @@ public void layoutContainer( Container c ) {
367368
368369 // hide buttons if not applicable
369370 boolean leftCollapsed = isLeftCollapsed ();
370- if ( leftCollapsed )
371+ boolean rightCollapsed = isRightCollapsed ();
372+ if ( leftCollapsed || rightCollapsed ) {
373+ leftButton .setVisible ( !leftCollapsed );
374+ rightButton .setVisible ( !rightCollapsed );
375+ } else {
376+ Object expandableSide = splitPane .getClientProperty ( FlatClientProperties .SPLIT_PANE_EXPANDABLE_SIDE );
377+ leftButton .setVisible ( expandableSide == null || !FlatClientProperties .SPLIT_PANE_EXPANDABLE_SIDE_LEFT .equals ( expandableSide ) );
378+ rightButton .setVisible ( expandableSide == null || !FlatClientProperties .SPLIT_PANE_EXPANDABLE_SIDE_RIGHT .equals ( expandableSide ) );
379+ }
380+
381+ // move right button if left button is hidden
382+ if ( !leftButton .isVisible () )
371383 rightButton .setLocation ( leftButton .getLocation () );
372- leftButton .setVisible ( !leftCollapsed );
373- rightButton .setVisible ( !isRightCollapsed () );
374384 }
375385 }
376386 }
0 commit comments