Skip to content

Commit

Permalink
TabbedPane: support specifying default tab layout policy for all tabb…
Browse files Browse the repository at this point in the history
…ed panes via UI value TabbedPane.tabLayoutPolicy
  • Loading branch information
DevCharly committed Nov 14, 2020
1 parent 634f7b5 commit f9e34cb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ FlatLaf Change Log
- TabbedPane: Support forward/backward scroll arrow buttons on both sides of tab
area. Backward button on left side, forward button on right side. Not
applicable scroll buttons are hidden. (PR #211; issue #40)
- TabbedPane: Support scrolling tabs with mouse wheel in scroll tab layout. (PR
- TabbedPane: Support specifying default tab layout policy for all tabbed panes
in the application via UI value `TabbedPane.tabLayoutPolicy`. E.g. invoke
`UIManager.put( "TabbedPane.tabLayoutPolicy", "scroll" );` to use scroll
layout.
- TabbedPane: Support tab scrolling with mouse wheel (in scroll tab layout). (PR
#187; issue #40)
- TabbedPane: Repeat scrolling as long as scroll arrow buttons are pressed. (PR
#187; issue #40)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@
* @uiDefault TabbedPane.tabSeparatorsFullHeight boolean
* @uiDefault TabbedPane.hasFullBorder boolean
*
* @uiDefault TabbedPane.tabLayoutPolicy String wrap (default) or scroll
* @uiDefault TabbedPane.tabsPopupPolicy String never or asNeeded (default)
* @uiDefault TabbedPane.scrollButtonsPolicy String never, asNeeded or asNeededSingle (default)
* @uiDefault TabbedPane.scrollButtonsPolicy String never, asNeeded or asNeededSingle (default)
* @uiDefault TabbedPane.scrollButtonsPlacement String both (default) or trailing
*
* @uiDefault TabbedPane.tabAreaAlignment String leading (default), center, trailing or fill
Expand Down Expand Up @@ -231,6 +232,18 @@ public static ComponentUI createUI( JComponent c ) {

@Override
public void installUI( JComponent c ) {
// initialize tab layout policy (if specified)
String tabLayoutPolicyStr = UIManager.getString( "TabbedPane.tabLayoutPolicy" );
if( tabLayoutPolicyStr != null ) {
int tabLayoutPolicy;
switch( tabLayoutPolicyStr ) {
default:
case "wrap": tabLayoutPolicy = JTabbedPane.WRAP_TAB_LAYOUT; break;
case "scroll": tabLayoutPolicy = JTabbedPane.SCROLL_TAB_LAYOUT; break;
}
((JTabbedPane)c).setTabLayoutPolicy( tabLayoutPolicy );
}

// initialize this defaults here because they are used in constructor
// of FlatTabAreaButton, which is invoked before installDefaults()
arrowType = UIManager.getString( "TabbedPane.arrowType" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,8 @@ TabbedPane.arrowType=chevron
TabbedPane.buttonInsets=2,1,2,1
TabbedPane.buttonArc=$Button.arc

# allowed values: wrap or scroll
#TabbedPane.tabLayoutPolicy=scroll
# allowed values: never or asNeeded
TabbedPane.tabsPopupPolicy=asNeeded
# allowed values: never, asNeeded or asNeededSingle
Expand Down

0 comments on commit f9e34cb

Please sign in to comment.