TabbedPane: support specifying tab area insets via client property

This commit is contained in:
Karl Tauber
2020-10-29 22:42:41 +01:00
parent da9d7a0dee
commit df13b338b2
3 changed files with 15 additions and 2 deletions

View File

@@ -284,6 +284,14 @@ public interface FlatClientProperties
*/
String TABBED_PANE_TAB_INSETS = "JTabbedPane.tabInsets";
/**
* Specifies the insets of the tab area.
* <p>
* <strong>Component</strong> {@link javax.swing.JTabbedPane}
* <strong>Value type</strong> {@link java.awt.Insets}
*/
String TABBED_PANE_TAB_AREA_INSETS = "JTabbedPane.tabAreaInsets";
/**
* Specifies whether tabs are closable.
* If set to {@code true} on a tabbed pane component, all tabs in that tabbed pane are closable.

View File

@@ -604,6 +604,10 @@ public class FlatTabbedPaneUI
Insets currentTabAreaInsets = super.getTabAreaInsets( tabPlacement );
Insets insets = (Insets) currentTabAreaInsets.clone();
Object value = tabPane.getClientProperty( TABBED_PANE_TAB_AREA_INSETS );
if( value instanceof Insets )
rotateInsets( (Insets) value, insets, tabPlacement );
// This is a "trick" to get rid of the cropped edge:
// super.getTabAreaInsets() returns private field BasicTabbedPaneUI.currentTabAreaInsets,
// which is also used to translate the origin of the cropped edge in
@@ -1937,6 +1941,7 @@ public class FlatTabbedPaneUI
case TABBED_PANE_MAXIMUM_TAB_WIDTH:
case TABBED_PANE_TAB_HEIGHT:
case TABBED_PANE_TAB_INSETS:
case TABBED_PANE_TAB_AREA_INSETS:
case TABBED_PANE_HIDDEN_TABS_NAVIGATION:
case TABBED_PANE_TAB_AREA_ALIGNMENT:
case TABBED_PANE_TAB_WIDTH_MODE:

View File

@@ -324,8 +324,8 @@ public class FlatContainerTest
}
private void tabAreaInsetsChanged() {
UIManager.put( "TabbedPane.tabAreaInsets", tabAreaInsetsCheckBox.isSelected() ? new Insets( 5, 5, 10, 10 ) : null );
FlatLaf.updateUI();
Insets insets = tabAreaInsetsCheckBox.isSelected() ? new Insets( 5, 5, 10, 10 ) : null;
putTabbedPanesClientProperty( TABBED_PANE_TAB_AREA_INSETS, insets );
}
private void smallerTabHeightChanged() {