TabbedPane: support horizontal alignment of tab title and icon

This commit is contained in:
Karl Tauber
2020-11-03 20:13:14 +01:00
parent 3a784375d0
commit a7e2a10403
12 changed files with 352 additions and 95 deletions

View File

@@ -25,6 +25,9 @@ FlatLaf Change Log
- TabbedPane: Support alignment of tab area. (set client property - TabbedPane: Support alignment of tab area. (set client property
`JTabbedPane.tabAreaAlignment` to `"leading"`, `"trailing"`, `"center"` or `JTabbedPane.tabAreaAlignment` to `"leading"`, `"trailing"`, `"center"` or
`"fill"`) (PR #199) `"fill"`) (PR #199)
- TabbedPane: Support horizontal alignment of tab title and icon. (set client
property `JTabbedPane.tabAlignment` to `SwingConstants.LEADING`,
`SwingConstants.TRAILING` or `SwingConstants.CENTER`)
- TabbedPane: Support equal and compact tab width modes. (set client property - TabbedPane: Support equal and compact tab width modes. (set client property
`JTabbedPane.tabWidthMode` to `"preferred"`, `"equal"` or `"compact"`) (PR `JTabbedPane.tabWidthMode` to `"preferred"`, `"equal"` or `"compact"`) (PR
#199) #199)

View File

@@ -33,8 +33,12 @@ public interface FlatClientProperties
* <p> * <p>
* <strong>Components</strong> {@link javax.swing.JButton} and {@link javax.swing.JToggleButton}<br> * <strong>Components</strong> {@link javax.swing.JButton} and {@link javax.swing.JToggleButton}<br>
* <strong>Value type</strong> {@link java.lang.String}<br> * <strong>Value type</strong> {@link java.lang.String}<br>
* <strong>Allowed Values</strong> {@link #BUTTON_TYPE_SQUARE}, {@link #BUTTON_TYPE_ROUND_RECT}, * <strong>Allowed Values</strong>
* {@link #BUTTON_TYPE_TAB}, {@link #BUTTON_TYPE_HELP} and {@link BUTTON_TYPE_TOOLBAR_BUTTON} * {@link #BUTTON_TYPE_SQUARE},
* {@link #BUTTON_TYPE_ROUND_RECT},
* {@link #BUTTON_TYPE_TAB},
* {@link #BUTTON_TYPE_HELP} or
* {@link BUTTON_TYPE_TOOLBAR_BUTTON}
*/ */
String BUTTON_TYPE = "JButton.buttonType"; String BUTTON_TYPE = "JButton.buttonType";
@@ -134,9 +138,12 @@ public interface FlatClientProperties
* {@link javax.swing.JScrollPane}, {@link javax.swing.JSpinner}, * {@link javax.swing.JScrollPane}, {@link javax.swing.JSpinner},
* {@link javax.swing.JTextField} and {@link javax.swing.JToggleButton}<br> * {@link javax.swing.JTextField} and {@link javax.swing.JToggleButton}<br>
* <strong>Value type</strong> {@link java.lang.String} or {@link java.awt.Color} or {@link java.awt.Color}[2]<br> * <strong>Value type</strong> {@link java.lang.String} or {@link java.awt.Color} or {@link java.awt.Color}[2]<br>
* <strong>Allowed Values</strong> {@link #OUTLINE_ERROR}, {@link #OUTLINE_WARNING}, * <strong>Allowed Values</strong>
* any color (type {@link java.awt.Color}) or an array of two colors (type {@link java.awt.Color}[2]) * {@link #OUTLINE_ERROR},
* where the first color is for focused state and the second for unfocused state * {@link #OUTLINE_WARNING},
* any color (type {@link java.awt.Color}) or
* an array of two colors (type {@link java.awt.Color}[2]) where the first color
* is for focused state and the second for unfocused state
*/ */
String OUTLINE = "JComponent.outline"; String OUTLINE = "JComponent.outline";
@@ -316,6 +323,8 @@ public interface FlatClientProperties
* <strong>Component</strong> {@link javax.swing.JTabbedPane} * <strong>Component</strong> {@link javax.swing.JTabbedPane}
* or tab content components (see {@link javax.swing.JTabbedPane#setComponentAt(int, java.awt.Component)})<br> * or tab content components (see {@link javax.swing.JTabbedPane#setComponentAt(int, java.awt.Component)})<br>
* <strong>Value type</strong> {@link java.lang.String} * <strong>Value type</strong> {@link java.lang.String}
*
* @see #TABBED_PANE_TAB_CLOSABLE
*/ */
String TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT = "JTabbedPane.tabCloseToolTipText"; String TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT = "JTabbedPane.tabCloseToolTipText";
@@ -384,48 +393,74 @@ public interface FlatClientProperties
* Specifies the alignment of the tab area. * Specifies the alignment of the tab area.
* <p> * <p>
* <strong>Component</strong> {@link javax.swing.JTabbedPane}<br> * <strong>Component</strong> {@link javax.swing.JTabbedPane}<br>
* <strong>Value type</strong> {@link java.lang.String}<br> * <strong>Value type</strong> {@link java.lang.Integer} or {@link java.lang.String}<br>
* <strong>Allowed Values</strong> {@link #TABBED_PANE_TAB_AREA_ALIGN_LEADING} (default), * <strong>Allowed Values</strong>
* {@link #TABBED_PANE_TAB_AREA_ALIGN_TRAILING}, {@link #TABBED_PANE_TAB_AREA_ALIGN_CENTER} * {@link SwingConstants#LEADING} (default)
* or {@link #TABBED_PANE_TAB_AREA_ALIGN_FILL} * {@link SwingConstants#TRAILING},
* {@link SwingConstants#CENTER},
* {@link #TABBED_PANE_ALIGN_LEADING} (default),
* {@link #TABBED_PANE_ALIGN_TRAILING},
* {@link #TABBED_PANE_ALIGN_CENTER} or
* {@link #TABBED_PANE_ALIGN_FILL}
*/ */
String TABBED_PANE_TAB_AREA_ALIGNMENT = "JTabbedPane.tabAreaAlignment"; String TABBED_PANE_TAB_AREA_ALIGNMENT = "JTabbedPane.tabAreaAlignment";
/** /**
* Align the tab area to the leading edge. * Specifies the horizontal alignment of the tab title and icon.
* * <p>
* @see #TABBED_PANE_TAB_AREA_ALIGNMENT * <strong>Component</strong> {@link javax.swing.JTabbedPane}
* or tab content components (see {@link javax.swing.JTabbedPane#setComponentAt(int, java.awt.Component)})<br>
* <strong>Value type</strong> {@link java.lang.Integer} or {@link java.lang.String}<br>
* <strong>Allowed Values</strong>
* {@link SwingConstants#LEADING},
* {@link SwingConstants#TRAILING},
* {@link SwingConstants#CENTER} (default),
* {@link #TABBED_PANE_ALIGN_LEADING},
* {@link #TABBED_PANE_ALIGN_TRAILING} or
* {@link #TABBED_PANE_ALIGN_CENTER} (default)
*/ */
String TABBED_PANE_TAB_AREA_ALIGN_LEADING = "leading"; String TABBED_PANE_TAB_ALIGNMENT = "JTabbedPane.tabAlignment";
/** /**
* Align the tab area to the trailing edge. * Align to the leading edge.
* *
* @see #TABBED_PANE_TAB_AREA_ALIGNMENT * @see #TABBED_PANE_TAB_AREA_ALIGNMENT
* @see #TABBED_PANE_TAB_ALIGNMENT
*/ */
String TABBED_PANE_TAB_AREA_ALIGN_TRAILING = "trailing"; String TABBED_PANE_ALIGN_LEADING = "leading";
/** /**
* Align the tab area to center. * Align to the trailing edge.
* *
* @see #TABBED_PANE_TAB_AREA_ALIGNMENT * @see #TABBED_PANE_TAB_AREA_ALIGNMENT
* @see #TABBED_PANE_TAB_ALIGNMENT
*/ */
String TABBED_PANE_TAB_AREA_ALIGN_CENTER = "center"; String TABBED_PANE_ALIGN_TRAILING = "trailing";
/** /**
* Stretch tabs to fill all available space. * Align to center.
*
* @see #TABBED_PANE_TAB_AREA_ALIGNMENT
* @see #TABBED_PANE_TAB_ALIGNMENT
*/
String TABBED_PANE_ALIGN_CENTER = "center";
/**
* Stretch to fill all available space.
* *
* @see #TABBED_PANE_TAB_AREA_ALIGNMENT * @see #TABBED_PANE_TAB_AREA_ALIGNMENT
*/ */
String TABBED_PANE_TAB_AREA_ALIGN_FILL = "fill"; String TABBED_PANE_ALIGN_FILL = "fill";
/** /**
* Specifies how the tabs should be sized. * Specifies how the tabs should be sized.
* <p> * <p>
* <strong>Component</strong> {@link javax.swing.JTabbedPane}<br> * <strong>Component</strong> {@link javax.swing.JTabbedPane}<br>
* <strong>Value type</strong> {@link java.lang.String}<br> * <strong>Value type</strong> {@link java.lang.String}<br>
* <strong>Allowed Values</strong> {@link #TABBED_PANE_TAB_WIDTH_MODE_PREFERRED} (default), * <strong>Allowed Values</strong>
* {@link #TABBED_PANE_TAB_WIDTH_MODE_EQUAL} or {@link #TABBED_PANE_TAB_WIDTH_MODE_COMPACT} * {@link #TABBED_PANE_TAB_WIDTH_MODE_PREFERRED} (default),
* {@link #TABBED_PANE_TAB_WIDTH_MODE_EQUAL} or
* {@link #TABBED_PANE_TAB_WIDTH_MODE_COMPACT}
*/ */
String TABBED_PANE_TAB_WIDTH_MODE = "JTabbedPane.tabWidthMode"; String TABBED_PANE_TAB_WIDTH_MODE = "JTabbedPane.tabWidthMode";
@@ -456,9 +491,11 @@ public interface FlatClientProperties
* <p> * <p>
* <strong>Component</strong> {@link javax.swing.JTabbedPane}<br> * <strong>Component</strong> {@link javax.swing.JTabbedPane}<br>
* <strong>Value type</strong> {@link java.lang.Integer}<br> * <strong>Value type</strong> {@link java.lang.Integer}<br>
* <strong>Allowed Values</strong> {@link SwingConstants#LEADING} (default), * <strong>Allowed Values</strong>
* {@link SwingConstants#TRAILING}, {@link SwingConstants#TOP} * {@link SwingConstants#LEADING} (default),
* or {@link SwingConstants#BOTTOM} * {@link SwingConstants#TRAILING},
* {@link SwingConstants#TOP} or
* {@link SwingConstants#BOTTOM}
*/ */
String TABBED_PANE_TAB_ICON_PLACEMENT = "JTabbedPane.tabIconPlacement"; String TABBED_PANE_TAB_ICON_PLACEMENT = "JTabbedPane.tabIconPlacement";
@@ -495,7 +532,8 @@ public interface FlatClientProperties
* <p> * <p>
* <strong>Component</strong> {@link javax.swing.JTextField} (and subclasses)<br> * <strong>Component</strong> {@link javax.swing.JTextField} (and subclasses)<br>
* <strong>Value type</strong> {@link java.lang.String}<br> * <strong>Value type</strong> {@link java.lang.String}<br>
* <strong>Allowed Values</strong> {@link #SELECT_ALL_ON_FOCUS_POLICY_NEVER}, * <strong>Allowed Values</strong>
* {@link #SELECT_ALL_ON_FOCUS_POLICY_NEVER},
* {@link #SELECT_ALL_ON_FOCUS_POLICY_ONCE} (default) or * {@link #SELECT_ALL_ON_FOCUS_POLICY_ONCE} (default) or
* {@link #SELECT_ALL_ON_FOCUS_POLICY_ALWAYS} * {@link #SELECT_ALL_ON_FOCUS_POLICY_ALWAYS}
*/ */

View File

@@ -128,6 +128,7 @@ import com.formdev.flatlaf.util.UIScale;
* @uiDefault TabbedPane.hasFullBorder boolean * @uiDefault TabbedPane.hasFullBorder boolean
* @uiDefault TabbedPane.hiddenTabsNavigation String moreTabsButton (default) or arrowButtons * @uiDefault TabbedPane.hiddenTabsNavigation String moreTabsButton (default) or arrowButtons
* @uiDefault TabbedPane.tabAreaAlignment String leading (default), center, trailing or fill * @uiDefault TabbedPane.tabAreaAlignment String leading (default), center, trailing or fill
* @uiDefault TabbedPane.tabAlignment String leading, center (default) or trailing
* @uiDefault TabbedPane.tabWidthMode String preferred (default), equal or compact * @uiDefault TabbedPane.tabWidthMode String preferred (default), equal or compact
* @uiDefault ScrollPane.smoothScrolling boolean * @uiDefault ScrollPane.smoothScrolling boolean
* @uiDefault TabbedPane.closeIcon Icon * @uiDefault TabbedPane.closeIcon Icon
@@ -144,10 +145,7 @@ public class FlatTabbedPaneUI
protected static final int ARROW_BUTTONS = 1; protected static final int ARROW_BUTTONS = 1;
// tab area alignment // tab area alignment
protected static final int ALIGN_LEADING = 0; protected static final int FILL = 100;
protected static final int ALIGN_TRAILING = 1;
protected static final int ALIGN_CENTER = 2;
protected static final int ALIGN_FILL = 3;
protected static final int WIDTH_MODE_PREFERRED = 0; protected static final int WIDTH_MODE_PREFERRED = 0;
protected static final int WIDTH_MODE_EQUAL = 1; protected static final int WIDTH_MODE_EQUAL = 1;
@@ -178,7 +176,8 @@ public class FlatTabbedPaneUI
protected boolean tabsOpaque = true; protected boolean tabsOpaque = true;
private String hiddenTabsNavigationStr; private String hiddenTabsNavigationStr;
private String tabAreaAlignmentStr; protected int tabAreaAlignment;
protected int tabAlignment;
private String tabWidthModeStr; private String tabWidthModeStr;
protected Icon closeIcon; protected Icon closeIcon;
@@ -246,7 +245,8 @@ public class FlatTabbedPaneUI
hasFullBorder = UIManager.getBoolean( "TabbedPane.hasFullBorder" ); hasFullBorder = UIManager.getBoolean( "TabbedPane.hasFullBorder" );
tabsOpaque = UIManager.getBoolean( "TabbedPane.tabsOpaque" ); tabsOpaque = UIManager.getBoolean( "TabbedPane.tabsOpaque" );
hiddenTabsNavigationStr = UIManager.getString( "TabbedPane.hiddenTabsNavigation" ); hiddenTabsNavigationStr = UIManager.getString( "TabbedPane.hiddenTabsNavigation" );
tabAreaAlignmentStr = UIManager.getString( "TabbedPane.tabAreaAlignment" ); tabAreaAlignment = parseAlignment( UIManager.getString( "TabbedPane.tabAreaAlignment" ), LEADING );
tabAlignment = parseAlignment( UIManager.getString( "TabbedPane.tabAlignment" ), CENTER );
tabWidthModeStr = UIManager.getString( "TabbedPane.tabWidthMode" ); tabWidthModeStr = UIManager.getString( "TabbedPane.tabWidthMode" );
closeIcon = UIManager.getIcon( "TabbedPane.closeIcon" ); closeIcon = UIManager.getIcon( "TabbedPane.closeIcon" );
@@ -1003,11 +1003,12 @@ public class FlatTabbedPaneUI
} }
// icon placement // icon placement
int iconPlacement = clientPropertyInt( tabPane, TABBED_PANE_TAB_ICON_PLACEMENT, LEADING ); int verticalTextPosition;
int verticalTextPosition = CENTER; int horizontalTextPosition;
int horizontalTextPosition = TRAILING; switch( clientPropertyInt( tabPane, TABBED_PANE_TAB_ICON_PLACEMENT, LEADING ) ) {
switch( iconPlacement ) { default:
case TRAILING: horizontalTextPosition = LEADING; break; case LEADING: verticalTextPosition = CENTER; horizontalTextPosition = TRAILING; break;
case TRAILING: verticalTextPosition = CENTER; horizontalTextPosition = LEADING; break;
case TOP: verticalTextPosition = BOTTOM; horizontalTextPosition = CENTER; break; case TOP: verticalTextPosition = BOTTOM; horizontalTextPosition = CENTER; break;
case BOTTOM: verticalTextPosition = TOP; horizontalTextPosition = CENTER; break; case BOTTOM: verticalTextPosition = TOP; horizontalTextPosition = CENTER; break;
} }
@@ -1023,7 +1024,7 @@ public class FlatTabbedPaneUI
// layout label // layout label
String clippedTitle = SwingUtilities.layoutCompoundLabel( tabPane, metrics, title, icon, String clippedTitle = SwingUtilities.layoutCompoundLabel( tabPane, metrics, title, icon,
CENTER, CENTER, verticalTextPosition, horizontalTextPosition, CENTER, getTabAlignment( tabIndex ), verticalTextPosition, horizontalTextPosition,
tabRect, iconRect, textRect, scale( textIconGapUnscaled ) ); tabRect, iconRect, textRect, scale( textIconGapUnscaled ) );
// remove temporary client property // remove temporary client property
@@ -1164,10 +1165,23 @@ public class FlatTabbedPaneUI
} }
protected int getTabAreaAlignment() { protected int getTabAreaAlignment() {
String str = (String) tabPane.getClientProperty( TABBED_PANE_TAB_AREA_ALIGNMENT ); Object value = tabPane.getClientProperty( TABBED_PANE_TAB_AREA_ALIGNMENT );
if( str == null ) if( value instanceof Integer )
str = tabAreaAlignmentStr; return (Integer) value;
return parseTabAreaAlignment( str );
return (value instanceof String)
? parseAlignment( (String) value, LEADING )
: tabAreaAlignment;
}
protected int getTabAlignment( int tabIndex ) {
Object value = getTabClientProperty( tabIndex, TABBED_PANE_TAB_ALIGNMENT );
if( value instanceof Integer )
return (Integer) value;
return (value instanceof String)
? parseAlignment( (String) value, CENTER )
: tabAlignment;
} }
protected int getTabWidthMode() { protected int getTabWidthMode() {
@@ -1188,16 +1202,16 @@ public class FlatTabbedPaneUI
} }
} }
protected static int parseTabAreaAlignment( String str ) { protected static int parseAlignment( String str, int defaultValue ) {
if( str == null ) if( str == null )
return ALIGN_LEADING; return defaultValue;
switch( str ) { switch( str ) {
default: case TABBED_PANE_ALIGN_LEADING: return LEADING;
case TABBED_PANE_TAB_AREA_ALIGN_LEADING: return ALIGN_LEADING; case TABBED_PANE_ALIGN_TRAILING: return TRAILING;
case TABBED_PANE_TAB_AREA_ALIGN_TRAILING: return ALIGN_TRAILING; case TABBED_PANE_ALIGN_CENTER: return CENTER;
case TABBED_PANE_TAB_AREA_ALIGN_CENTER: return ALIGN_CENTER; case TABBED_PANE_ALIGN_FILL: return FILL;
case TABBED_PANE_TAB_AREA_ALIGN_FILL: return ALIGN_FILL; default: return defaultValue;
} }
} }
@@ -1972,6 +1986,7 @@ public class FlatTabbedPaneUI
case TABBED_PANE_TAB_AREA_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_ALIGNMENT:
case TABBED_PANE_TAB_WIDTH_MODE: case TABBED_PANE_TAB_WIDTH_MODE:
case TABBED_PANE_TAB_ICON_PLACEMENT: case TABBED_PANE_TAB_ICON_PLACEMENT:
case TABBED_PANE_TAB_CLOSABLE: case TABBED_PANE_TAB_CLOSABLE:
@@ -2013,6 +2028,7 @@ public class FlatTabbedPaneUI
case TABBED_PANE_MINIMUM_TAB_WIDTH: case TABBED_PANE_MINIMUM_TAB_WIDTH:
case TABBED_PANE_MAXIMUM_TAB_WIDTH: case TABBED_PANE_MAXIMUM_TAB_WIDTH:
case TABBED_PANE_TAB_INSETS: case TABBED_PANE_TAB_INSETS:
case TABBED_PANE_TAB_ALIGNMENT:
case TABBED_PANE_TAB_CLOSABLE: case TABBED_PANE_TAB_CLOSABLE:
tabPane.revalidate(); tabPane.revalidate();
tabPane.repaint(); tabPane.repaint();
@@ -2161,22 +2177,22 @@ public class FlatTabbedPaneUI
int diff = availWidth - totalTabWidth; int diff = availWidth - totalTabWidth;
switch( tabAreaAlignment ) { switch( tabAreaAlignment ) {
case ALIGN_LEADING: case LEADING:
trailingWidth += diff; trailingWidth += diff;
break; break;
case ALIGN_TRAILING: case TRAILING:
shiftTabs( leftToRight ? diff : -diff, 0 ); shiftTabs( leftToRight ? diff : -diff, 0 );
leadingWidth += diff; leadingWidth += diff;
break; break;
case ALIGN_CENTER: case CENTER:
shiftTabs( (leftToRight ? diff : -diff) / 2, 0 ); shiftTabs( (leftToRight ? diff : -diff) / 2, 0 );
leadingWidth += diff / 2; leadingWidth += diff / 2;
trailingWidth += diff - (diff / 2); trailingWidth += diff - (diff / 2);
break; break;
case ALIGN_FILL: case FILL:
stretchTabsWidth( diff, leftToRight ); stretchTabsWidth( diff, leftToRight );
break; break;
} }
@@ -2220,22 +2236,22 @@ public class FlatTabbedPaneUI
int diff = availHeight - totalTabHeight; int diff = availHeight - totalTabHeight;
switch( tabAreaAlignment ) { switch( tabAreaAlignment ) {
case ALIGN_LEADING: case LEADING:
bottomHeight += diff; bottomHeight += diff;
break; break;
case ALIGN_TRAILING: case TRAILING:
shiftTabs( 0, diff ); shiftTabs( 0, diff );
topHeight += diff; topHeight += diff;
break; break;
case ALIGN_CENTER: case CENTER:
shiftTabs( 0, (diff) / 2 ); shiftTabs( 0, (diff) / 2 );
topHeight += diff / 2; topHeight += diff / 2;
bottomHeight += diff - (diff / 2); bottomHeight += diff - (diff / 2);
break; break;
case ALIGN_FILL: case FILL:
stretchTabsHeight( diff ); stretchTabsHeight( diff );
break; break;
} }
@@ -2405,20 +2421,20 @@ public class FlatTabbedPaneUI
if( totalTabWidth < availWidth && rects.length > 0 ) { if( totalTabWidth < availWidth && rects.length > 0 ) {
int diff = availWidth - totalTabWidth; int diff = availWidth - totalTabWidth;
switch( tabAreaAlignment ) { switch( tabAreaAlignment ) {
case ALIGN_LEADING: case LEADING:
trailingWidth += diff; trailingWidth += diff;
break; break;
case ALIGN_TRAILING: case TRAILING:
leadingWidth += diff; leadingWidth += diff;
break; break;
case ALIGN_CENTER: case CENTER:
leadingWidth += diff / 2; leadingWidth += diff / 2;
trailingWidth += diff - (diff / 2); trailingWidth += diff - (diff / 2);
break; break;
case ALIGN_FILL: case FILL:
stretchTabsWidth( diff, leftToRight ); stretchTabsWidth( diff, leftToRight );
totalTabWidth = rectsTotalWidth( leftToRight ); totalTabWidth = rectsTotalWidth( leftToRight );
break; break;
@@ -2492,20 +2508,20 @@ public class FlatTabbedPaneUI
if( totalTabHeight < availHeight && rects.length > 0 ) { if( totalTabHeight < availHeight && rects.length > 0 ) {
int diff = availHeight - totalTabHeight; int diff = availHeight - totalTabHeight;
switch( tabAreaAlignment ) { switch( tabAreaAlignment ) {
case ALIGN_LEADING: case LEADING:
bottomHeight += diff; bottomHeight += diff;
break; break;
case ALIGN_TRAILING: case TRAILING:
topHeight += diff; topHeight += diff;
break; break;
case ALIGN_CENTER: case CENTER:
topHeight += diff / 2; topHeight += diff / 2;
bottomHeight += diff - (diff / 2); bottomHeight += diff - (diff / 2);
break; break;
case ALIGN_FILL: case FILL:
stretchTabsHeight( diff ); stretchTabsHeight( diff );
totalTabHeight = rectsTotalHeight(); totalTabHeight = rectsTotalHeight();
break; break;

View File

@@ -552,6 +552,7 @@ TabbedPane.shadow=@background
TabbedPane.contentBorderInsets=null TabbedPane.contentBorderInsets=null
TabbedPane.hiddenTabsNavigation=moreTabsButton TabbedPane.hiddenTabsNavigation=moreTabsButton
TabbedPane.tabAreaAlignment=leading TabbedPane.tabAreaAlignment=leading
TabbedPane.tabAlignment=center
TabbedPane.closeIcon=com.formdev.flatlaf.icons.FlatTabbedPaneCloseIcon TabbedPane.closeIcon=com.formdev.flatlaf.icons.FlatTabbedPaneCloseIcon
TabbedPane.closeSize=16,16 TabbedPane.closeSize=16,16

View File

@@ -53,10 +53,15 @@ class TabsPanel
initTabIconPlacement( iconLeadingTabbedPane, SwingConstants.LEADING ); initTabIconPlacement( iconLeadingTabbedPane, SwingConstants.LEADING );
initTabIconPlacement( iconTrailingTabbedPane, SwingConstants.TRAILING ); initTabIconPlacement( iconTrailingTabbedPane, SwingConstants.TRAILING );
initTabAreaAlignment( alignLeadingTabbedPane, TABBED_PANE_TAB_AREA_ALIGN_LEADING ); initTabAreaAlignment( alignLeadingTabbedPane, TABBED_PANE_ALIGN_LEADING );
initTabAreaAlignment( alignCenterTabbedPane, TABBED_PANE_TAB_AREA_ALIGN_CENTER ); initTabAreaAlignment( alignCenterTabbedPane, TABBED_PANE_ALIGN_CENTER );
initTabAreaAlignment( alignTrailingTabbedPane, TABBED_PANE_TAB_AREA_ALIGN_TRAILING ); initTabAreaAlignment( alignTrailingTabbedPane, TABBED_PANE_ALIGN_TRAILING );
initTabAreaAlignment( alignFillTabbedPane, TABBED_PANE_TAB_AREA_ALIGN_FILL ); initTabAreaAlignment( alignFillTabbedPane, TABBED_PANE_ALIGN_FILL );
initTabAlignment( tabAlignLeadingTabbedPane, SwingConstants.LEADING );
initTabAlignment( tabAlignCenterTabbedPane, SwingConstants.CENTER );
initTabAlignment( tabAlignTrailingTabbedPane, SwingConstants.TRAILING );
initTabAlignment( tabAlignVerticalTabbedPane, SwingConstants.TRAILING );
initTabWidthMode( widthPreferredTabbedPane, TABBED_PANE_TAB_WIDTH_MODE_PREFERRED ); initTabWidthMode( widthPreferredTabbedPane, TABBED_PANE_TAB_WIDTH_MODE_PREFERRED );
initTabWidthMode( widthEqualTabbedPane, TABBED_PANE_TAB_WIDTH_MODE_EQUAL ); initTabWidthMode( widthEqualTabbedPane, TABBED_PANE_TAB_WIDTH_MODE_EQUAL );
@@ -223,7 +228,7 @@ class TabsPanel
int iconSize = topOrBottom ? 24 : 16; int iconSize = topOrBottom ? 24 : 16;
tabbedPane.putClientProperty( TABBED_PANE_TAB_ICON_PLACEMENT, iconPlacement ); tabbedPane.putClientProperty( TABBED_PANE_TAB_ICON_PLACEMENT, iconPlacement );
if( topOrBottom ) { if( topOrBottom ) {
tabbedPane.putClientProperty( TABBED_PANE_TAB_AREA_ALIGNMENT, TABBED_PANE_TAB_AREA_ALIGN_FILL ); tabbedPane.putClientProperty( TABBED_PANE_TAB_AREA_ALIGNMENT, TABBED_PANE_ALIGN_FILL );
tabbedPane.putClientProperty( TABBED_PANE_TAB_WIDTH_MODE, TABBED_PANE_TAB_WIDTH_MODE_EQUAL ); tabbedPane.putClientProperty( TABBED_PANE_TAB_WIDTH_MODE, TABBED_PANE_TAB_WIDTH_MODE_EQUAL );
} }
tabbedPane.addTab( "Search", new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/search.svg", iconSize, iconSize ), null ); tabbedPane.addTab( "Search", new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/search.svg", iconSize, iconSize ), null );
@@ -238,6 +243,18 @@ class TabsPanel
tabbedPane.addTab( "Recents", null ); tabbedPane.addTab( "Recents", null );
} }
private void initTabAlignment( JTabbedPane tabbedPane, int tabAlignment ) {
boolean vertical = (tabbedPane.getTabPlacement() == JTabbedPane.LEFT || tabbedPane.getTabPlacement() == JTabbedPane.RIGHT);
tabbedPane.putClientProperty( TABBED_PANE_TAB_ALIGNMENT, tabAlignment );
if( !vertical )
tabbedPane.putClientProperty( TABBED_PANE_MINIMUM_TAB_WIDTH, 80 );
tabbedPane.addTab( "A", null );
if( vertical ) {
tabbedPane.addTab( "Search", null );
tabbedPane.addTab( "Recents", null );
}
}
private void initTabWidthMode( JTabbedPane tabbedPane, String tabWidthMode ) { private void initTabWidthMode( JTabbedPane tabbedPane, String tabWidthMode ) {
tabbedPane.putClientProperty( TABBED_PANE_TAB_WIDTH_MODE, tabWidthMode ); tabbedPane.putClientProperty( TABBED_PANE_TAB_WIDTH_MODE, tabWidthMode );
if( tabWidthMode.equals( TABBED_PANE_TAB_WIDTH_MODE_COMPACT ) ) { if( tabWidthMode.equals( TABBED_PANE_TAB_WIDTH_MODE_COMPACT ) ) {
@@ -337,6 +354,14 @@ class TabsPanel
JLabel minMaxTabWidthLabel = new JLabel(); JLabel minMaxTabWidthLabel = new JLabel();
minimumTabWidthTabbedPane = new JTabbedPane(); minimumTabWidthTabbedPane = new JTabbedPane();
maximumTabWidthTabbedPane = new JTabbedPane(); maximumTabWidthTabbedPane = new JTabbedPane();
JLabel tabAlignmentLabel = new JLabel();
panel5 = new JPanel();
JLabel tabAlignmentNoteLabel = new JLabel();
JLabel tabAlignmentNoteLabel2 = new JLabel();
tabAlignLeadingTabbedPane = new JTabbedPane();
tabAlignVerticalTabbedPane = new JTabbedPane();
tabAlignCenterTabbedPane = new JTabbedPane();
tabAlignTrailingTabbedPane = new JTabbedPane();
JPanel panel4 = new JPanel(); JPanel panel4 = new JPanel();
showTabSeparatorsCheckBox = new JCheckBox(); showTabSeparatorsCheckBox = new JCheckBox();
@@ -681,6 +706,8 @@ class TabsPanel
"[]para" + "[]para" +
"[]" + "[]" +
"[]" + "[]" +
"[]para" +
"[]0" +
"[]")); "[]"));
//---- tabWidthModeLabel ---- //---- tabWidthModeLabel ----
@@ -731,6 +758,67 @@ class TabsPanel
maximumTabWidthTabbedPane.setName("maximumTabWidthTabbedPane"); maximumTabWidthTabbedPane.setName("maximumTabWidthTabbedPane");
} }
panel3.add(maximumTabWidthTabbedPane, "cell 0 7"); panel3.add(maximumTabWidthTabbedPane, "cell 0 7");
//---- tabAlignmentLabel ----
tabAlignmentLabel.setText("Tab title alignment");
tabAlignmentLabel.setFont(tabAlignmentLabel.getFont().deriveFont(tabAlignmentLabel.getFont().getSize() + 4f));
tabAlignmentLabel.setName("tabAlignmentLabel");
panel3.add(tabAlignmentLabel, "cell 0 8");
//======== panel5 ========
{
panel5.setName("panel5");
panel5.setLayout(new MigLayout(
"insets 0,hidemode 3",
// columns
"[grow,fill]para" +
"[fill]",
// rows
"[]" +
"[]" +
"[]" +
"[]"));
//---- tabAlignmentNoteLabel ----
tabAlignmentNoteLabel.setText("(leading/center/trailing)");
tabAlignmentNoteLabel.setEnabled(false);
tabAlignmentNoteLabel.setFont(tabAlignmentNoteLabel.getFont().deriveFont(tabAlignmentNoteLabel.getFont().getSize() - 2f));
tabAlignmentNoteLabel.setName("tabAlignmentNoteLabel");
panel5.add(tabAlignmentNoteLabel, "cell 0 0");
//---- tabAlignmentNoteLabel2 ----
tabAlignmentNoteLabel2.setText("(trailing)");
tabAlignmentNoteLabel2.setEnabled(false);
tabAlignmentNoteLabel2.setFont(tabAlignmentNoteLabel2.getFont().deriveFont(tabAlignmentNoteLabel2.getFont().getSize() - 2f));
tabAlignmentNoteLabel2.setName("tabAlignmentNoteLabel2");
panel5.add(tabAlignmentNoteLabel2, "cell 1 0,alignx right,growx 0");
//======== tabAlignLeadingTabbedPane ========
{
tabAlignLeadingTabbedPane.setName("tabAlignLeadingTabbedPane");
}
panel5.add(tabAlignLeadingTabbedPane, "cell 0 1");
//======== tabAlignVerticalTabbedPane ========
{
tabAlignVerticalTabbedPane.setTabPlacement(SwingConstants.LEFT);
tabAlignVerticalTabbedPane.setName("tabAlignVerticalTabbedPane");
}
panel5.add(tabAlignVerticalTabbedPane, "cell 1 1 1 3,growy");
//======== tabAlignCenterTabbedPane ========
{
tabAlignCenterTabbedPane.setName("tabAlignCenterTabbedPane");
}
panel5.add(tabAlignCenterTabbedPane, "cell 0 2");
//======== tabAlignTrailingTabbedPane ========
{
tabAlignTrailingTabbedPane.setName("tabAlignTrailingTabbedPane");
}
panel5.add(tabAlignTrailingTabbedPane, "cell 0 3");
}
panel3.add(panel5, "cell 0 9");
} }
add(panel3, "cell 2 0"); add(panel3, "cell 2 0");
@@ -759,16 +847,16 @@ class TabsPanel
tabPlacementButtonGroup.add(leftPlacementButton); tabPlacementButtonGroup.add(leftPlacementButton);
tabPlacementButtonGroup.add(rightPlacementButton); tabPlacementButtonGroup.add(rightPlacementButton);
//---- buttonGroup2 ---- //---- tabLayoutButtonGroup ----
ButtonGroup buttonGroup2 = new ButtonGroup(); ButtonGroup tabLayoutButtonGroup = new ButtonGroup();
buttonGroup2.add(scrollTabLayoutButton); tabLayoutButtonGroup.add(scrollTabLayoutButton);
buttonGroup2.add(wrapTabLayoutButton); tabLayoutButtonGroup.add(wrapTabLayoutButton);
//---- buttonGroup1 ---- //---- closableTabsButtonGroup ----
ButtonGroup buttonGroup1 = new ButtonGroup(); ButtonGroup closableTabsButtonGroup = new ButtonGroup();
buttonGroup1.add(squareCloseButton); closableTabsButtonGroup.add(squareCloseButton);
buttonGroup1.add(circleCloseButton); closableTabsButtonGroup.add(circleCloseButton);
buttonGroup1.add(redCrossCloseButton); closableTabsButtonGroup.add(redCrossCloseButton);
// JFormDesigner - End of component initialization //GEN-END:initComponents // JFormDesigner - End of component initialization //GEN-END:initComponents
} }
@@ -810,6 +898,11 @@ class TabsPanel
private JTabbedPane widthCompactTabbedPane; private JTabbedPane widthCompactTabbedPane;
private JTabbedPane minimumTabWidthTabbedPane; private JTabbedPane minimumTabWidthTabbedPane;
private JTabbedPane maximumTabWidthTabbedPane; private JTabbedPane maximumTabWidthTabbedPane;
private JPanel panel5;
private JTabbedPane tabAlignLeadingTabbedPane;
private JTabbedPane tabAlignVerticalTabbedPane;
private JTabbedPane tabAlignCenterTabbedPane;
private JTabbedPane tabAlignTrailingTabbedPane;
private JCheckBox showTabSeparatorsCheckBox; private JCheckBox showTabSeparatorsCheckBox;
// JFormDesigner - End of variables declaration //GEN-END:variables // JFormDesigner - End of variables declaration //GEN-END:variables
} }

View File

@@ -102,7 +102,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "scrollTabLayoutButton" name: "scrollTabLayoutButton"
"text": "scroll" "text": "scroll"
"$buttonGroup": new FormReference( "buttonGroup2" ) "$buttonGroup": new FormReference( "tabLayoutButtonGroup" )
"font": &SwingDerivedFont2 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) "font": &SwingDerivedFont2 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false )
"selected": true "selected": true
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabLayoutChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabLayoutChanged", false ) )
@@ -110,7 +110,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "wrapTabLayoutButton" name: "wrapTabLayoutButton"
"text": "wrap" "text": "wrap"
"$buttonGroup": new FormReference( "buttonGroup2" ) "$buttonGroup": new FormReference( "tabLayoutButtonGroup" )
"font": #SwingDerivedFont2 "font": #SwingDerivedFont2
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabLayoutChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabLayoutChanged", false ) )
} ) } )
@@ -161,7 +161,7 @@ new FormModel {
name: "squareCloseButton" name: "squareCloseButton"
"text": "square" "text": "square"
"font": &SwingDerivedFont4 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) "font": &SwingDerivedFont4 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false )
"$buttonGroup": new FormReference( "buttonGroup1" ) "$buttonGroup": new FormReference( "closableTabsButtonGroup" )
"selected": true "selected": true
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "closeButtonStyleChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "closeButtonStyleChanged", false ) )
} ) } )
@@ -169,14 +169,14 @@ new FormModel {
name: "circleCloseButton" name: "circleCloseButton"
"text": "circle" "text": "circle"
"font": #SwingDerivedFont4 "font": #SwingDerivedFont4
"$buttonGroup": new FormReference( "buttonGroup1" ) "$buttonGroup": new FormReference( "closableTabsButtonGroup" )
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "closeButtonStyleChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "closeButtonStyleChanged", false ) )
} ) } )
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "redCrossCloseButton" name: "redCrossCloseButton"
"text": "red cross" "text": "red cross"
"font": #SwingDerivedFont4 "font": #SwingDerivedFont4
"$buttonGroup": new FormReference( "buttonGroup1" ) "$buttonGroup": new FormReference( "closableTabsButtonGroup" )
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "closeButtonStyleChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "closeButtonStyleChanged", false ) )
} ) } )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -290,7 +290,7 @@ new FormModel {
name: "tabAreaAlignmentNoteLabel" name: "tabAreaAlignmentNoteLabel"
"text": "(leading/center/trailing/fill)" "text": "(leading/center/trailing/fill)"
"enabled": false "enabled": false
"font": new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) "font": &SwingDerivedFont7 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false )
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": true "JavaCodeGenerator.variableLocal": true
} }
@@ -323,7 +323,7 @@ new FormModel {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3" "$layoutConstraints": "insets 0,hidemode 3"
"$columnConstraints": "[grow,fill]" "$columnConstraints": "[grow,fill]"
"$rowConstraints": "[]0[][][][]para[][][]" "$rowConstraints": "[]0[][][][]para[][][]para[]0[]"
} ) { } ) {
name: "panel3" name: "panel3"
auxiliary() { auxiliary() {
@@ -385,6 +385,68 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7" "value": "cell 0 7"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "tabAlignmentLabel"
"text": "Tab title alignment"
"font": #SwingDerivedFont6
auxiliary() {
"JavaCodeGenerator.variableLocal": true
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[grow,fill]para[fill]"
"$rowConstraints": "[][][][]"
"$layoutConstraints": "insets 0,hidemode 3"
} ) {
name: "panel5"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "tabAlignmentNoteLabel"
"text": "(leading/center/trailing)"
"enabled": false
"font": #SwingDerivedFont7
auxiliary() {
"JavaCodeGenerator.variableLocal": true
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "tabAlignmentNoteLabel2"
"text": "(trailing)"
"enabled": false
"font": #SwingDerivedFont7
auxiliary() {
"JavaCodeGenerator.variableLocal": true
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0,alignx right,growx 0"
} )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabAlignLeadingTabbedPane"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabAlignVerticalTabbedPane"
"tabPlacement": 2
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1 1 3,growy"
} )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabAlignCenterTabbedPane"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabAlignTrailingTabbedPane"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 9"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0" "value": "cell 2 0"
} ) } )
@@ -412,22 +474,22 @@ new FormModel {
} ) } )
}, new FormLayoutConstraints( null ) { }, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 ) "location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 925, 825 ) "size": new java.awt.Dimension( 1075, 860 )
} ) } )
add( new FormNonVisual( "javax.swing.ButtonGroup" ) { add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
name: "tabPlacementButtonGroup" name: "tabPlacementButtonGroup"
}, new FormLayoutConstraints( null ) { }, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 10, 1240 ) "location": new java.awt.Point( 5, 915 )
} ) } )
add( new FormNonVisual( "javax.swing.ButtonGroup" ) { add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
name: "buttonGroup1" name: "closableTabsButtonGroup"
}, new FormLayoutConstraints( null ) { }, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 1292 ) "location": new java.awt.Point( 5, 970 )
} ) } )
add( new FormNonVisual( "javax.swing.ButtonGroup" ) { add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
name: "buttonGroup2" name: "tabLayoutButtonGroup"
}, new FormLayoutConstraints( null ) { }, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 1344 ) "location": new java.awt.Point( 5, 1020 )
} ) } )
} }
} }

View File

@@ -937,6 +937,7 @@ TabbedPane.selectedTabPadInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI
TabbedPane.selectionFollowsFocus true TabbedPane.selectionFollowsFocus true
TabbedPane.shadow #3c3f41 javax.swing.plaf.ColorUIResource [UI] TabbedPane.shadow #3c3f41 javax.swing.plaf.ColorUIResource [UI]
TabbedPane.showTabSeparators false TabbedPane.showTabSeparators false
TabbedPane.tabAlignment center
TabbedPane.tabAreaAlignment leading TabbedPane.tabAreaAlignment leading
TabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] TabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
TabbedPane.tabHeight 32 TabbedPane.tabHeight 32

View File

@@ -942,6 +942,7 @@ TabbedPane.selectedTabPadInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI
TabbedPane.selectionFollowsFocus true TabbedPane.selectionFollowsFocus true
TabbedPane.shadow #f2f2f2 javax.swing.plaf.ColorUIResource [UI] TabbedPane.shadow #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
TabbedPane.showTabSeparators false TabbedPane.showTabSeparators false
TabbedPane.tabAlignment center
TabbedPane.tabAreaAlignment leading TabbedPane.tabAreaAlignment leading
TabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] TabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
TabbedPane.tabHeight 32 TabbedPane.tabHeight 32

View File

@@ -932,6 +932,7 @@ TabbedPane.selectedTabPadInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI
TabbedPane.selectionFollowsFocus true TabbedPane.selectionFollowsFocus true
TabbedPane.shadow #ccffcc javax.swing.plaf.ColorUIResource [UI] TabbedPane.shadow #ccffcc javax.swing.plaf.ColorUIResource [UI]
TabbedPane.showTabSeparators false TabbedPane.showTabSeparators false
TabbedPane.tabAlignment center
TabbedPane.tabAreaAlignment leading TabbedPane.tabAreaAlignment leading
TabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] TabbedPane.tabAreaInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
TabbedPane.tabHeight 32 TabbedPane.tabHeight 32

View File

@@ -276,6 +276,17 @@ public class FlatContainerTest
putTabbedPanesClientProperty( TABBED_PANE_TAB_AREA_ALIGNMENT, value ); putTabbedPanesClientProperty( TABBED_PANE_TAB_AREA_ALIGNMENT, value );
} }
private void tabAlignmentChanged() {
String value = (String) tabAlignmentField.getSelectedItem();
Integer tabAlignment = null;
switch( value ) {
case "center": tabAlignment = SwingConstants.CENTER; break;
case "leading": tabAlignment = SwingConstants.LEADING; break;
case "trailing": tabAlignment = SwingConstants.TRAILING; break;
}
putTabbedPanesClientProperty( TABBED_PANE_TAB_ALIGNMENT, tabAlignment );
}
private void tabWidthModeChanged() { private void tabWidthModeChanged() {
String value = (String) tabWidthModeField.getSelectedItem(); String value = (String) tabWidthModeField.getSelectedItem();
if( "default".equals( value ) ) if( "default".equals( value ) )
@@ -416,6 +427,7 @@ public class FlatContainerTest
iconPlacementField = new JComboBox<>(); iconPlacementField = new JComboBox<>();
JLabel tabAreaAlignmentLabel = new JLabel(); JLabel tabAreaAlignmentLabel = new JLabel();
tabAreaAlignmentField = new JComboBox<>(); tabAreaAlignmentField = new JComboBox<>();
tabAlignmentField = new JComboBox<>();
JLabel tabWidthModeLabel = new JLabel(); JLabel tabWidthModeLabel = new JLabel();
tabWidthModeField = new JComboBox<>(); tabWidthModeField = new JComboBox<>();
tabsClosableCheckBox = new JCheckBox(); tabsClosableCheckBox = new JCheckBox();
@@ -637,7 +649,7 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(iconPlacementField, "cell 2 2"); tabbedPaneControlPanel.add(iconPlacementField, "cell 2 2");
//---- tabAreaAlignmentLabel ---- //---- tabAreaAlignmentLabel ----
tabAreaAlignmentLabel.setText("Tab area alignment:"); tabAreaAlignmentLabel.setText("Tab area/title alignment:");
tabbedPaneControlPanel.add(tabAreaAlignmentLabel, "cell 0 3"); tabbedPaneControlPanel.add(tabAreaAlignmentLabel, "cell 0 3");
//---- tabAreaAlignmentField ---- //---- tabAreaAlignmentField ----
@@ -651,6 +663,16 @@ public class FlatContainerTest
tabAreaAlignmentField.addActionListener(e -> tabAreaAlignmentChanged()); tabAreaAlignmentField.addActionListener(e -> tabAreaAlignmentChanged());
tabbedPaneControlPanel.add(tabAreaAlignmentField, "cell 1 3"); tabbedPaneControlPanel.add(tabAreaAlignmentField, "cell 1 3");
//---- tabAlignmentField ----
tabAlignmentField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"leading",
"trailing",
"center"
}));
tabAlignmentField.addActionListener(e -> tabAlignmentChanged());
tabbedPaneControlPanel.add(tabAlignmentField, "cell 1 3");
//---- tabWidthModeLabel ---- //---- tabWidthModeLabel ----
tabWidthModeLabel.setText("Tab width mode:"); tabWidthModeLabel.setText("Tab width mode:");
tabbedPaneControlPanel.add(tabWidthModeLabel, "cell 2 3"); tabbedPaneControlPanel.add(tabWidthModeLabel, "cell 2 3");
@@ -760,6 +782,7 @@ public class FlatContainerTest
private JSpinner tabIconSizeSpinner; private JSpinner tabIconSizeSpinner;
private JComboBox<String> iconPlacementField; private JComboBox<String> iconPlacementField;
private JComboBox<String> tabAreaAlignmentField; private JComboBox<String> tabAreaAlignmentField;
private JComboBox<String> tabAlignmentField;
private JComboBox<String> tabWidthModeField; private JComboBox<String> tabWidthModeField;
private JCheckBox tabsClosableCheckBox; private JCheckBox tabsClosableCheckBox;
private JCheckBox customBorderCheckBox; private JCheckBox customBorderCheckBox;

View File

@@ -300,7 +300,7 @@ new FormModel {
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "tabAreaAlignmentLabel" name: "tabAreaAlignmentLabel"
"text": "Tab area alignment:" "text": "Tab area/title alignment:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3" "value": "cell 0 3"
} ) } )
@@ -322,6 +322,23 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3" "value": "cell 1 3"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "tabAlignmentField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "leading" )
addElement( "trailing" )
addElement( "center" )
}
auxiliary() {
"JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String"
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAlignmentChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3"
} )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "tabWidthModeLabel" name: "tabWidthModeLabel"
"text": "Tab width mode:" "text": "Tab width mode:"

View File

@@ -667,6 +667,7 @@ TabbedPane.selectedTabPadInsets
TabbedPane.selectionFollowsFocus TabbedPane.selectionFollowsFocus
TabbedPane.shadow TabbedPane.shadow
TabbedPane.showTabSeparators TabbedPane.showTabSeparators
TabbedPane.tabAlignment
TabbedPane.tabAreaAlignment TabbedPane.tabAreaAlignment
TabbedPane.tabAreaInsets TabbedPane.tabAreaInsets
TabbedPane.tabHeight TabbedPane.tabHeight