TabbedPane custom components on left and right sides of tabs area #192
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces support for adding custom components to left and right sides of tabs area.
Set client properties
JTabbedPane.leadingComponent
orJTabbedPane.trailingComponent
on aJTabbedPane
to add components:The preferred width of the added components is used, but the height is always set to the tab height.
Use an additional panel if your component should have a smaller height.
Edit: since commit dc92d09 the trailing component occupies all available horizontal space, which allows you to use all space on the right side of the tabs:
There is no gap between the leading/trailing components and the tabs.
If you want place buttons into the tab area, it is recommended to use a
JToolBar
:(code from FlatLaf Demo)
Because the trailing component occupies all available space, it is necessary to add a horizontal glue with
javax.swing.Box.createHorizontalGlue()
to the toolbar to get right aligned buttons:This is part of TabbedPane improvements as discussed in issue #40 (comment).
CC @smileatom @Chrriis