Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TabbedPane: tab area alignment; min/max tab widths; tab icon placement; tab width mode #199

Merged
merged 9 commits into from
Nov 1, 2020

Conversation

DevCharly
Copy link
Collaborator

@DevCharly DevCharly commented Oct 29, 2020

Tab area alignment

By default the tab area is aligned to the left edge.
Now you can also align it to the right, center or fill.

grafik
grafik
grafik
grafik

To use this for the whole application (allowed values are leading, trailing, center and fill:

UIManager.put( "TabbedPane.tabAreaAlignment", "center" );

To use this for single tabbed pane:

myTabbedPane.putClientProperty( "JTabbedPane.tabAreaAlignment", "center" );

Minimum/maximum tab width

With this PR you can now specify minimum and maximum tab widths.
This is useful for IDE like applications where you e.g. use file names in tab titles.
With minimum tab width you can avoid small tabs for short file names.
With maximum tab width you can avoid too wide tabs for long file names.

Minimum tab width makes tabs wider:
grafik

Maximum tab width makes tabs smaller:
grafik

myTabbedPane.putClientProperty( "JTabbedPane.minimumTabWidth", 100 );
myTabbedPane.putClientProperty( "JTabbedPane.maximumTabWidth", 200 );

Tab icon placement

You can now specify the tab icon placement (relative to tab title),
which makes it easy to create tabs in a style that you know from
your smartphone or tablet.

grafik

myTabbedPane.putClientProperty( "JTabbedPane.tabIconPlacement", SwingConstants.TOP );
myTabbedPane.putClientProperty( "JTabbedPane.tabIconPlacement", SwingConstants.BOTTOM );
myTabbedPane.putClientProperty( "JTabbedPane.tabIconPlacement", SwingConstants.LEADING ); // default
myTabbedPane.putClientProperty( "JTabbedPane.tabIconPlacement", SwingConstants.TRAILING );

Tab width mode

With the "width mode" you can make all tabs equal width or hide tab title of unselected tabs. Available modes:

  • preferred: tab width is adjusted to tab icon and title (the default)
  • equal: all tabs in a tabbed pane has same width
  • compact: unselected tabs show only the tab icon, but no tab title; selected tabs show both; works only if tab has icon

grafik

grafik

myTabbedPane.putClientProperty( "JTabbedPane.tabWidthMode", "preferred" ); // default
myTabbedPane.putClientProperty( "JTabbedPane.tabWidthMode", "equal" );
myTabbedPane.putClientProperty( "JTabbedPane.tabWidthMode", "compact" );

@DevCharly DevCharly changed the title Tabbedpane: tab area alignment; minimum/maximum tab widths Tabbedpane: tab area alignment; min/max tab widths; tab icon placement; tab width mode Nov 1, 2020
@DevCharly DevCharly changed the title Tabbedpane: tab area alignment; min/max tab widths; tab icon placement; tab width mode TabbedPane: tab area alignment; min/max tab widths; tab icon placement; tab width mode Nov 1, 2020
@DevCharly DevCharly merged commit a47565a into master Nov 1, 2020
@DevCharly DevCharly added this to the 0.44 milestone Nov 1, 2020
@DevCharly DevCharly deleted the tabbedpane-layout branch November 1, 2020 20:40
@DevCharly DevCharly mentioned this pull request Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant