mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 07:17:13 -06:00
TabbedPane: support specifying tab area insets via client property
This commit is contained in:
@@ -284,6 +284,14 @@ public interface FlatClientProperties
|
|||||||
*/
|
*/
|
||||||
String TABBED_PANE_TAB_INSETS = "JTabbedPane.tabInsets";
|
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.
|
* Specifies whether tabs are closable.
|
||||||
* If set to {@code true} on a tabbed pane component, all tabs in that tabbed pane are closable.
|
* If set to {@code true} on a tabbed pane component, all tabs in that tabbed pane are closable.
|
||||||
|
|||||||
@@ -604,6 +604,10 @@ public class FlatTabbedPaneUI
|
|||||||
Insets currentTabAreaInsets = super.getTabAreaInsets( tabPlacement );
|
Insets currentTabAreaInsets = super.getTabAreaInsets( tabPlacement );
|
||||||
Insets insets = (Insets) currentTabAreaInsets.clone();
|
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:
|
// This is a "trick" to get rid of the cropped edge:
|
||||||
// super.getTabAreaInsets() returns private field BasicTabbedPaneUI.currentTabAreaInsets,
|
// super.getTabAreaInsets() returns private field BasicTabbedPaneUI.currentTabAreaInsets,
|
||||||
// which is also used to translate the origin of the cropped edge in
|
// 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_MAXIMUM_TAB_WIDTH:
|
||||||
case TABBED_PANE_TAB_HEIGHT:
|
case TABBED_PANE_TAB_HEIGHT:
|
||||||
case TABBED_PANE_TAB_INSETS:
|
case TABBED_PANE_TAB_INSETS:
|
||||||
|
case TABBED_PANE_TAB_AREA_INSETS:
|
||||||
case TABBED_PANE_HIDDEN_TABS_NAVIGATION:
|
case TABBED_PANE_HIDDEN_TABS_NAVIGATION:
|
||||||
case TABBED_PANE_TAB_AREA_ALIGNMENT:
|
case TABBED_PANE_TAB_AREA_ALIGNMENT:
|
||||||
case TABBED_PANE_TAB_WIDTH_MODE:
|
case TABBED_PANE_TAB_WIDTH_MODE:
|
||||||
|
|||||||
@@ -324,8 +324,8 @@ public class FlatContainerTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void tabAreaInsetsChanged() {
|
private void tabAreaInsetsChanged() {
|
||||||
UIManager.put( "TabbedPane.tabAreaInsets", tabAreaInsetsCheckBox.isSelected() ? new Insets( 5, 5, 10, 10 ) : null );
|
Insets insets = tabAreaInsetsCheckBox.isSelected() ? new Insets( 5, 5, 10, 10 ) : null;
|
||||||
FlatLaf.updateUI();
|
putTabbedPanesClientProperty( TABBED_PANE_TAB_AREA_INSETS, insets );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void smallerTabHeightChanged() {
|
private void smallerTabHeightChanged() {
|
||||||
|
|||||||
Reference in New Issue
Block a user