Extras: added extension class for JTabbedPane (issue #117)

This commit is contained in:
Karl Tauber
2020-12-11 23:44:52 +01:00
parent ab51f35d5d
commit 534384438b
5 changed files with 693 additions and 220 deletions

View File

@@ -264,7 +264,7 @@ public interface FlatClientProperties
String TABBED_PANE_HAS_FULL_BORDER = "JTabbedPane.hasFullBorder"; String TABBED_PANE_HAS_FULL_BORDER = "JTabbedPane.hasFullBorder";
/** /**
* Specifies whether the tab area should be hidded if it contains only one tab. * Specifies whether the tab area should be hidden if it contains only one tab.
* <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.Boolean} * <strong>Value type</strong> {@link java.lang.Boolean}
@@ -349,7 +349,7 @@ public interface FlatClientProperties
* Specifies the callback that is invoked when a tab close button is clicked. * Specifies the callback that is invoked when a tab close button is clicked.
* The callback is responsible for closing the tab. * The callback is responsible for closing the tab.
* <p> * <p>
* Either use a {@link java.util.function.IntConsumer} that received the tab index as parameter: * Either use a {@link java.util.function.IntConsumer} that receives the tab index as parameter:
* <pre>{@code * <pre>{@code
* myTabbedPane.putClientProperty( "JTabbedPane.tabCloseCallback", * myTabbedPane.putClientProperty( "JTabbedPane.tabCloseCallback",
* (IntConsumer) tabIndex -> { * (IntConsumer) tabIndex -> {
@@ -357,7 +357,7 @@ public interface FlatClientProperties
* } ); * } );
* }</pre> * }</pre>
* Or use a {@link java.util.function.BiConsumer}&lt;javax.swing.JTabbedPane, Integer&gt; * Or use a {@link java.util.function.BiConsumer}&lt;javax.swing.JTabbedPane, Integer&gt;
* that received the tabbed pane and the tab index as parameters: * that receives the tabbed pane and the tab index as parameters:
* <pre>{@code * <pre>{@code
* myTabbedPane.putClientProperty( "JTabbedPane.tabCloseCallback", * myTabbedPane.putClientProperty( "JTabbedPane.tabCloseCallback",
* (BiConsumer<JTabbedPane, Integer>) (tabbedPane, tabIndex) -> { * (BiConsumer<JTabbedPane, Integer>) (tabbedPane, tabIndex) -> {

View File

@@ -17,6 +17,7 @@
package com.formdev.flatlaf.extras.components; package com.formdev.flatlaf.extras.components;
import java.awt.Color; import java.awt.Color;
import java.awt.Insets;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.UIManager; import javax.swing.UIManager;
@@ -70,6 +71,11 @@ public interface FlatComponentExtension
return (value instanceof Color) ? (Color) value : UIManager.getColor( defaultValueKey ); return (value instanceof Color) ? (Color) value : UIManager.getColor( defaultValueKey );
} }
default Insets getClientPropertyInsets( Object key, String defaultValueKey ) {
Object value = getClientProperty( key );
return (value instanceof Insets) ? (Insets) value : UIManager.getInsets( defaultValueKey );
}
default <T extends Enum<T>> T getClientPropertyEnumString( Object key, Class<T> enumType, default <T extends Enum<T>> T getClientPropertyEnumString( Object key, Class<T> enumType,
String defaultValueKey, T defaultValue ) String defaultValueKey, T defaultValue )

View File

@@ -0,0 +1,537 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Component;
import java.awt.Insets;
import java.util.function.BiConsumer;
import javax.swing.JComponent;
import javax.swing.JTabbedPane;
import javax.swing.SwingConstants;
/**
* Subclass of {@link JTabbedPane} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatTabbedPane
extends JTabbedPane
implements FlatComponentExtension
{
/**
* Returns whether separators are shown between tabs.
*/
public boolean isShowTabSeparators() {
return getClientPropertyBoolean( TABBED_PANE_SHOW_TAB_SEPARATORS, "TabbedPane.showTabSeparators" );
}
/**
* Specifies whether separators are shown between tabs.
*/
public void setShowTabSeparators( boolean showTabSeparators ) {
putClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators );
}
/**
* Returns whether the separator between tabs area and content area should be shown.
*/
public boolean isShowContentSeparators() {
return getClientPropertyBoolean( TABBED_PANE_SHOW_CONTENT_SEPARATOR, true );
}
/**
* Specifies whether the separator between tabs area and content area should be shown.
*/
public void setShowContentSeparators( boolean showContentSeparators ) {
putClientPropertyBoolean( TABBED_PANE_SHOW_CONTENT_SEPARATOR, showContentSeparators, true );
}
/**
* Returns whether a full border is painted around a tabbed pane.
*/
public boolean isHasFullBorder() {
return getClientPropertyBoolean( TABBED_PANE_HAS_FULL_BORDER, "TabbedPane.hasFullBorder" );
}
/**
* Specifies whether a full border is painted around a tabbed pane.
*/
public void setHasFullBorder( boolean hasFullBorder ) {
putClientProperty( TABBED_PANE_HAS_FULL_BORDER, hasFullBorder );
}
/**
* Returns whether the tab area should be hidden if it contains only one tab.
*/
public boolean isHideTabAreaWithOneTab() {
return getClientPropertyBoolean( TABBED_PANE_HIDE_TAB_AREA_WITH_ONE_TAB, false );
}
/**
* Specifies whether the tab area should be hidden if it contains only one tab.
*/
public void setHideTabAreaWithOneTab( boolean hideTabAreaWithOneTab ) {
putClientPropertyBoolean( TABBED_PANE_HIDE_TAB_AREA_WITH_ONE_TAB, hideTabAreaWithOneTab, false );
}
/**
* Returns the minimum width of a tab.
*/
public int getMinimumTabWidth() {
return getClientPropertyInt( TABBED_PANE_MINIMUM_TAB_WIDTH, "TabbedPane.minimumTabWidth" );
}
/**
* Specifies the minimum width of a tab.
*/
public void setMinimumTabWidth( int minimumTabWidth ) {
putClientProperty( TABBED_PANE_MINIMUM_TAB_WIDTH, (minimumTabWidth >= 0) ? minimumTabWidth : null );
}
/**
* Returns the minimum width of the tab at the given tab index.
*/
public int getMinimumTabWidth( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return clientPropertyInt( c, TABBED_PANE_MINIMUM_TAB_WIDTH, 0 );
}
/**
* Specifies the minimum width of the tab at the given tab index.
*/
public void setMinimumTabWidth( int tabIndex, int minimumTabWidth ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_MINIMUM_TAB_WIDTH, (minimumTabWidth >= 0) ? minimumTabWidth : null );
}
/**
* Returns the maximum width of a tab.
*/
public int getMaximumTabWidth() {
return getClientPropertyInt( TABBED_PANE_MAXIMUM_TAB_WIDTH, "TabbedPane.maximumTabWidth" );
}
/**
* Specifies the maximum width of a tab.
* <p>
* Applied only if tab does not have a custom tab component
* (see {@link javax.swing.JTabbedPane#setTabComponentAt(int, java.awt.Component)}).
*/
public void setMaximumTabWidth( int maximumTabWidth ) {
putClientProperty( TABBED_PANE_MAXIMUM_TAB_WIDTH, (maximumTabWidth >= 0) ? maximumTabWidth : null );
}
/**
* Returns the maximum width of the tab at the given tab index.
*/
public int getMaximumTabWidth( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return clientPropertyInt( c, TABBED_PANE_MAXIMUM_TAB_WIDTH, 0 );
}
/**
* Specifies the maximum width of the tab at the given tab index.
* <p>
* Applied only if tab does not have a custom tab component
* (see {@link javax.swing.JTabbedPane#setTabComponentAt(int, java.awt.Component)}).
*/
public void setMaximumTabWidth( int tabIndex, int maximumTabWidth ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_MAXIMUM_TAB_WIDTH, (maximumTabWidth >= 0) ? maximumTabWidth : null );
}
/**
* Returns the height of a tab.
*/
public int getTabHeight() {
return getClientPropertyInt( TABBED_PANE_TAB_HEIGHT, "TabbedPane.tabHeight" );
}
/**
* Specifies the height of a tab.
*/
public void setTabHeight( int tabHeight ) {
putClientProperty( TABBED_PANE_TAB_HEIGHT, (tabHeight >= 0) ? tabHeight : null );
}
/**
* Returns the insets of a tab.
*/
public Insets getTabInsets() {
return getClientPropertyInsets( TABBED_PANE_TAB_INSETS, "TabbedPane.tabInsets" );
}
/**
* Specifies the insets of a tab.
*/
public void setTabInsets( Insets tabInsets ) {
putClientProperty( TABBED_PANE_TAB_INSETS, tabInsets );
}
/**
* Returns the insets of the tab at the given tab index.
*/
public Insets getTabInsets( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return (Insets) c.getClientProperty( TABBED_PANE_TAB_INSETS );
}
/**
* Specifies the insets of the tab at the given tab index.
*/
public void setTabInsets( int tabIndex, Insets tabInsets ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_TAB_INSETS, tabInsets );
}
/**
* Returns the insets of the tab area.
*/
public Insets getTabAreaInsets() {
return getClientPropertyInsets( TABBED_PANE_TAB_AREA_INSETS, "TabbedPane.tabAreaInsets" );
}
/**
* Specifies the insets of the tab area.
*/
public void setTabAreaInsets( Insets tabAreaInsets ) {
putClientProperty( TABBED_PANE_TAB_AREA_INSETS, tabAreaInsets );
}
/**
* Returns whether all tabs are closable.
*/
public boolean isTabsClosable() {
return getClientPropertyBoolean( TABBED_PANE_TAB_CLOSABLE, false );
}
/**
* Specifies whether all tabs are closable.
* If set to {@code true}, all tabs in that tabbed pane are closable.
* To make individual tabs closable, use {@link #setTabClosable(int, boolean)}.
* <p>
* Note that you have to specify a callback (see {@link #setTabCloseCallback(BiConsumer)})
* that is invoked when the user clicks a tab close button.
* The callback is responsible for closing the tab.
*/
public void setTabsClosable( boolean tabClosable ) {
putClientPropertyBoolean( TABBED_PANE_TAB_CLOSABLE, tabClosable, false );
}
/**
* Returns whether the tab at the given tab index is closable.
*/
public Boolean isTabClosable( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
Object value = c.getClientProperty( TABBED_PANE_TAB_CLOSABLE );
return (value instanceof Boolean) ? (boolean) value : isTabsClosable();
}
/**
* Specifies whether the tab at the given tab index is closable.
* To make all tabs closable, use {@link #setTabsClosable(boolean)}.
* <p>
* Note that you have to specify a callback (see {@link #setTabCloseCallback(BiConsumer)})
* that is invoked when the user clicks a tab close button.
* The callback is responsible for closing the tab.
*/
public void setTabClosable( int tabIndex, boolean tabClosable ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_TAB_CLOSABLE, tabClosable );
}
/**
* Returns the tooltip text used for tab close buttons.
*/
public String getTabCloseToolTipText() {
return (String) getClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT );
}
/**
* Specifies the tooltip text used for tab close buttons.
*/
public void setTabCloseToolTipText( String tabCloseToolTipText ) {
putClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT, tabCloseToolTipText );
}
/**
* Returns the tooltip text used for tab close button at the given tab index.
*/
public String getTabCloseToolTipText( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return (String) c.getClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT );
}
/**
* Specifies the tooltip text used for tab close button at the given tab index.
*/
public void setTabCloseToolTipText( int tabIndex, String tabCloseToolTipText ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT, tabCloseToolTipText );
}
/**
* Returns the callback that is invoked when a tab close button is clicked.
* The callback is responsible for closing the tab.
*/
@SuppressWarnings( "unchecked" )
public BiConsumer<JTabbedPane, Integer> getTabCloseCallback() {
return (BiConsumer<JTabbedPane, Integer>) getClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK );
}
/**
* Specifies the callback that is invoked when a tab close button is clicked.
* The callback is responsible for closing the tab.
* <p>
* Use a {@link java.util.function.BiConsumer}&lt;javax.swing.JTabbedPane, Integer&gt;
* that receives the tabbed pane and the tab index as parameters:
* <pre>{@code
* myTabbedPane.setTabCloseCallback( (tabbedPane, tabIndex) -> {
* // close tab here
* } );
* }</pre>
* If you need to check whether a modifier key (e.g. Alt or Shift) was pressed
* while the user clicked the tab close button, use {@link java.awt.EventQueue#getCurrentEvent}
* to get current event, check whether it is a {@link java.awt.event.MouseEvent}
* and invoke its methods. E.g.
* <pre>{@code
* AWTEvent e = EventQueue.getCurrentEvent();
* boolean shift = (e instanceof MouseEvent) ? ((MouseEvent)e).isShiftDown() : false;
* }</pre>
*/
public void setTabCloseCallback( BiConsumer<JTabbedPane, Integer> tabCloseCallback ) {
putClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK, tabCloseCallback );
}
/**
* Returns the callback that is invoked when the tab close button at the given tab index is clicked.
* The callback is responsible for closing the tab.
*/
@SuppressWarnings( "unchecked" )
public BiConsumer<JTabbedPane, Integer> getTabCloseCallback( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return (BiConsumer<JTabbedPane, Integer>) c.getClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK );
}
/**
* Specifies the callback that is invoked when the tab close button at the given tab index is clicked.
* The callback is responsible for closing the tab.
*
* @see #setTabCloseCallback(BiConsumer)
*/
public void setTabCloseCallback( int tabIndex, BiConsumer<JTabbedPane, Integer> tabCloseCallback ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK, tabCloseCallback );
}
// NOTE: enum names must be equal to allowed strings
public enum TabsPopupPolicy { never, asNeeded };
/**
* Returns the display policy for the "more tabs" button,
* which shows a popup menu with the (partly) hidden tabs.
*/
public TabsPopupPolicy getTabsPopupPolicy() {
return getClientPropertyEnumString( TABBED_PANE_TABS_POPUP_POLICY, TabsPopupPolicy.class,
"TabbedPane.tabsPopupPolicy", TabsPopupPolicy.asNeeded );
}
/**
* Specifies the display policy for the "more tabs" button,
* which shows a popup menu with the (partly) hidden tabs.
*/
public void setTabsPopupPolicy( TabsPopupPolicy tabsPopupPolicy ) {
putClientPropertyEnumString( TABBED_PANE_TABS_POPUP_POLICY, tabsPopupPolicy );
}
// NOTE: enum names must be equal to allowed strings
public enum ScrollButtonsPolicy { never, asNeeded, asNeededSingle };
/**
* Returns the display policy for the forward/backward scroll arrow buttons.
*/
public ScrollButtonsPolicy getScrollButtonsPolicy() {
return getClientPropertyEnumString( TABBED_PANE_SCROLL_BUTTONS_POLICY, ScrollButtonsPolicy.class,
"TabbedPane.scrollButtonsPolicy", ScrollButtonsPolicy.asNeededSingle );
}
/**
* Specifies the display policy for the forward/backward scroll arrow buttons.
*/
public void setScrollButtonsPolicy( ScrollButtonsPolicy scrollButtonsPolicy ) {
putClientPropertyEnumString( TABBED_PANE_SCROLL_BUTTONS_POLICY, scrollButtonsPolicy );
}
// NOTE: enum names must be equal to allowed strings
public enum ScrollButtonsPlacement { both, trailing };
/**
* Returns the placement of the forward/backward scroll arrow buttons.
*/
public ScrollButtonsPlacement getScrollButtonsPlacement() {
return getClientPropertyEnumString( TABBED_PANE_SCROLL_BUTTONS_PLACEMENT, ScrollButtonsPlacement.class,
"TabbedPane.scrollButtonsPlacement", ScrollButtonsPlacement.both );
}
/**
* Specifies the placement of the forward/backward scroll arrow buttons.
*/
public void setScrollButtonsPlacement( ScrollButtonsPlacement scrollButtonsPlacement ) {
putClientPropertyEnumString( TABBED_PANE_SCROLL_BUTTONS_PLACEMENT, scrollButtonsPlacement );
}
// NOTE: enum names must be equal to allowed strings
public enum TabAreaAlignment { leading, trailing, center, fill };
/**
* Returns the alignment of the tab area.
*/
public TabAreaAlignment getTabAreaAlignment() {
return getClientPropertyEnumString( TABBED_PANE_TAB_AREA_ALIGNMENT, TabAreaAlignment.class,
"TabbedPane.tabAreaAlignment", TabAreaAlignment.leading );
}
/**
* Specifies the alignment of the tab area.
*/
public void setTabAreaAlignment( TabAreaAlignment tabAreaAlignment ) {
putClientPropertyEnumString( TABBED_PANE_TAB_AREA_ALIGNMENT, tabAreaAlignment );
}
// NOTE: enum names must be equal to allowed strings
public enum TabAlignment { leading, trailing, center };
/**
* Returns the horizontal alignment of the tab title and icon.
*/
public TabAlignment getTabAlignment() {
return getClientPropertyEnumString( TABBED_PANE_TAB_ALIGNMENT, TabAlignment.class,
"TabbedPane.tabAlignment", TabAlignment.center );
}
/**
* Specifies the horizontal alignment of the tab title and icon.
*/
public void setTabAlignment( TabAlignment tabAlignment ) {
putClientPropertyEnumString( TABBED_PANE_TAB_ALIGNMENT, tabAlignment );
}
// NOTE: enum names must be equal to allowed strings
public enum TabWidthMode { preferred, equal, compact };
/**
* Returns how the tabs should be sized.
*/
public TabWidthMode getTabWidthMode() {
return getClientPropertyEnumString( TABBED_PANE_TAB_WIDTH_MODE, TabWidthMode.class,
"TabbedPane.tabWidthMode", TabWidthMode.preferred );
}
/**
* Specifies how the tabs should be sized.
*/
public void setTabWidthMode( TabWidthMode tabWidthMode ) {
putClientPropertyEnumString( TABBED_PANE_TAB_WIDTH_MODE, tabWidthMode );
}
/**
* Returns the tab icon placement (relative to tab title).
*/
public int getTabIconPlacement() {
return getClientPropertyInt( TABBED_PANE_TAB_ICON_PLACEMENT, SwingConstants.LEADING );
}
/**
* Specifies the tab icon placement (relative to tab title).
* <p>
* Allowed Values are:
* <ul>
* <li>{@link SwingConstants#LEADING} (default)
* <li>{@link SwingConstants#TRAILING}
* <li>{@link SwingConstants#TOP}
* <li>{@link SwingConstants#BOTTOM}
* </ul>
*/
public void setTabIconPlacement( int tabIconPlacement ) {
putClientProperty( TABBED_PANE_TAB_ICON_PLACEMENT, (tabIconPlacement >= 0) ? tabIconPlacement : null );
}
/**
* Returns a component that will be placed at the leading edge of the tabs area.
*/
public Component getLeadingComponent() {
return (Component) getClientProperty( TABBED_PANE_LEADING_COMPONENT );
}
/**
* Specifies a component that will be placed at the leading edge of the tabs area.
* <p>
* For top and bottom tab placement, the layed out component size will be
* the preferred component width and the tab area height.<br>
* For left and right tab placement, the layed out component size will be
* the tab area width and the preferred component height.
*/
public void setLeadingComponent( Component leadingComponent ) {
putClientProperty( TABBED_PANE_LEADING_COMPONENT, leadingComponent );
}
/**
* Returns a component that will be placed at the trailing edge of the tabs area.
*/
public Component getTrailingComponent() {
return (Component) getClientProperty( TABBED_PANE_TRAILING_COMPONENT );
}
/**
* Specifies a component that will be placed at the trailing edge of the tabs area.
* <p>
* For top and bottom tab placement, the layed out component size will be
* the available horizontal space (minimum is preferred component width) and the tab area height.<br>
* For left and right tab placement, the layed out component size will be
* the tab area width and the available vertical space (minimum is preferred component height).
*/
public void setTrailingComponent( Component trailingComponent ) {
putClientProperty( TABBED_PANE_TRAILING_COMPONENT, trailingComponent );
}
}

View File

@@ -19,11 +19,12 @@ package com.formdev.flatlaf.testing;
import static com.formdev.flatlaf.FlatClientProperties.*; import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.*; import java.awt.*;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.function.BiConsumer;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*; import javax.swing.border.*;
import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.extras.TriStateCheckBox; import com.formdev.flatlaf.extras.TriStateCheckBox;
import com.formdev.flatlaf.extras.components.FlatTabbedPane;
import com.formdev.flatlaf.extras.components.FlatTabbedPane.*;
import com.formdev.flatlaf.icons.FlatInternalFrameCloseIcon; import com.formdev.flatlaf.icons.FlatInternalFrameCloseIcon;
import com.formdev.flatlaf.util.ScaledImageIcon; import com.formdev.flatlaf.util.ScaledImageIcon;
import com.jgoodies.forms.layout.*; import com.jgoodies.forms.layout.*;
@@ -46,11 +47,21 @@ public class FlatContainerTest
public FlatContainerTest() { public FlatContainerTest() {
initComponents(); initComponents();
tabPlacementField.init( TabPlacement.class, true );
iconPlacementField.init( TabIconPlacement.class, true );
tabsPopupPolicyField.init( TabsPopupPolicy.class, true );
scrollButtonsPolicyField.init( ScrollButtonsPolicy.class, true );
scrollButtonsPlacementField.init( ScrollButtonsPlacement.class, true );
tabAreaAlignmentField.init( TabAreaAlignment.class, true );
tabAlignmentField.init( TabAlignment.class, true );
tabWidthModeField.init( TabWidthMode.class, true );
tabCountChanged(); tabCountChanged();
tabsClosableCheckBox.setSelected( true ); tabsClosableCheckBox.setSelected( true );
tabsClosableChanged(); tabsClosableChanged();
putTabbedPanesClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT, "Close" ); for( FlatTabbedPane tabbedPane : allTabbedPanes )
tabbedPane.setTabCloseToolTipText( "Close" );
tabScrollCheckBox.setSelected( true ); tabScrollCheckBox.setSelected( true );
tabScrollChanged(); tabScrollChanged();
@@ -79,7 +90,7 @@ public class FlatContainerTest
} }
private void hideTabAreaWithOneTabChanged() { private void hideTabAreaWithOneTabChanged() {
boolean hideTabAreaWithOneTab = hideTabAreaWithOneTabCheckBox.isSelected(); Boolean hideTabAreaWithOneTab = hideTabAreaWithOneTabCheckBox.isSelected() ? true : null;
putTabbedPanesClientProperty( TABBED_PANE_HIDE_TAB_AREA_WITH_ONE_TAB, hideTabAreaWithOneTab ); putTabbedPanesClientProperty( TABBED_PANE_HIDE_TAB_AREA_WITH_ONE_TAB, hideTabAreaWithOneTab );
} }
@@ -158,6 +169,7 @@ public class FlatContainerTest
setTabIcons( tabbedPane ); setTabIcons( tabbedPane );
tabIconSizeSpinner.setEnabled( tabIconsCheckBox.isSelected() ); tabIconSizeSpinner.setEnabled( tabIconsCheckBox.isSelected() );
iconPlacementField.setEnabled( tabIconsCheckBox.isSelected() );
} }
private void setTabIcons( JTabbedPane tabbedPane ) { private void setTabIcons( JTabbedPane tabbedPane ) {
@@ -182,14 +194,10 @@ public class FlatContainerTest
} }
private void iconPlacementChanged() { private void iconPlacementChanged() {
Object iconPlacement = null; TabIconPlacement value = iconPlacementField.getSelectedValue();
switch( (String) iconPlacementField.getSelectedItem() ) { int iconPlacement = (value != null) ? value.value : -1;
case "leading": iconPlacement = SwingConstants.LEADING; break; for( FlatTabbedPane tabbedPane : allTabbedPanes )
case "trailing": iconPlacement = SwingConstants.TRAILING; break; tabbedPane.setTabIconPlacement( iconPlacement );
case "top": iconPlacement = SwingConstants.TOP; break;
case "bottom": iconPlacement = SwingConstants.BOTTOM; break;
}
putTabbedPanesClientProperty( TABBED_PANE_TAB_ICON_PLACEMENT, iconPlacement );
} }
private void customBorderChanged() { private void customBorderChanged() {
@@ -252,13 +260,8 @@ public class FlatContainerTest
} }
private void tabPlacementChanged() { private void tabPlacementChanged() {
int tabPlacement = -1; TabPlacement value = tabPlacementField.getSelectedValue();
switch( (String) tabPlacementField.getSelectedItem() ) { int tabPlacement = (value != null) ? value.value : -1;
case "top": tabPlacement = SwingConstants.TOP; break;
case "bottom": tabPlacement = SwingConstants.BOTTOM; break;
case "left": tabPlacement = SwingConstants.LEFT; break;
case "right": tabPlacement = SwingConstants.RIGHT; break;
}
tabbedPane1.setTabPlacement( (tabPlacement >= 0) ? tabPlacement : SwingConstants.TOP ); tabbedPane1.setTabPlacement( (tabPlacement >= 0) ? tabPlacement : SwingConstants.TOP );
tabbedPane2.setTabPlacement( (tabPlacement >= 0) ? tabPlacement : SwingConstants.BOTTOM ); tabbedPane2.setTabPlacement( (tabPlacement >= 0) ? tabPlacement : SwingConstants.BOTTOM );
@@ -267,49 +270,39 @@ public class FlatContainerTest
} }
private void tabsPopupPolicyChanged() { private void tabsPopupPolicyChanged() {
String value = (String) tabsPopupPolicyField.getSelectedItem(); TabsPopupPolicy value = tabsPopupPolicyField.getSelectedValue();
if( "default".equals( value ) ) for( FlatTabbedPane tabbedPane : allTabbedPanes )
value = null; tabbedPane.setTabsPopupPolicy( value );
putTabbedPanesClientProperty( TABBED_PANE_TABS_POPUP_POLICY, value );
} }
private void scrollButtonsPolicyChanged() { private void scrollButtonsPolicyChanged() {
String value = (String) scrollButtonsPolicyField.getSelectedItem(); ScrollButtonsPolicy value = scrollButtonsPolicyField.getSelectedValue();
if( "default".equals( value ) ) for( FlatTabbedPane tabbedPane : allTabbedPanes )
value = null; tabbedPane.setScrollButtonsPolicy( value );
putTabbedPanesClientProperty( TABBED_PANE_SCROLL_BUTTONS_POLICY, value );
} }
private void scrollButtonsPlacementChanged() { private void scrollButtonsPlacementChanged() {
String value = (String) scrollButtonsPlacementField.getSelectedItem(); ScrollButtonsPlacement value = scrollButtonsPlacementField.getSelectedValue();
if( "default".equals( value ) ) for( FlatTabbedPane tabbedPane : allTabbedPanes )
value = null; tabbedPane.setScrollButtonsPlacement( value );
putTabbedPanesClientProperty( TABBED_PANE_SCROLL_BUTTONS_PLACEMENT, value );
} }
private void tabAreaAlignmentChanged() { private void tabAreaAlignmentChanged() {
String value = (String) tabAreaAlignmentField.getSelectedItem(); TabAreaAlignment value = tabAreaAlignmentField.getSelectedValue();
if( "default".equals( value ) ) for( FlatTabbedPane tabbedPane : allTabbedPanes )
value = null; tabbedPane.setTabAreaAlignment( value );
putTabbedPanesClientProperty( TABBED_PANE_TAB_AREA_ALIGNMENT, value );
} }
private void tabAlignmentChanged() { private void tabAlignmentChanged() {
String value = (String) tabAlignmentField.getSelectedItem(); TabAlignment value = tabAlignmentField.getSelectedValue();
Integer tabAlignment = null; for( FlatTabbedPane tabbedPane : allTabbedPanes )
switch( value ) { tabbedPane.setTabAlignment( 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(); TabWidthMode value = tabWidthModeField.getSelectedValue();
if( "default".equals( value ) ) for( FlatTabbedPane tabbedPane : allTabbedPanes )
value = null; tabbedPane.setTabWidthMode( value );
putTabbedPanesClientProperty( TABBED_PANE_TAB_WIDTH_MODE, value );
} }
private void tabBackForegroundChanged() { private void tabBackForegroundChanged() {
@@ -349,65 +342,74 @@ public class FlatContainerTest
private void tabsClosableChanged() { private void tabsClosableChanged() {
boolean closable = tabsClosableCheckBox.isSelected(); boolean closable = tabsClosableCheckBox.isSelected();
putTabbedPanesClientProperty( TABBED_PANE_TAB_CLOSABLE, closable ? true : null ); for( FlatTabbedPane tabbedPane : allTabbedPanes )
tabbedPane.setTabsClosable( closable );
if( closable ) { if( closable ) {
putTabbedPanesClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK, for( FlatTabbedPane tabbedPane : allTabbedPanes ) {
(BiConsumer<JTabbedPane, Integer>) (tabbedPane, tabIndex) -> { tabbedPane.setTabCloseCallback( (tabbedPane2, tabIndex) -> {
AWTEvent e = EventQueue.getCurrentEvent(); AWTEvent e = EventQueue.getCurrentEvent();
int modifiers = (e instanceof MouseEvent) ? ((MouseEvent)e).getModifiers() : 0; int modifiers = (e instanceof MouseEvent) ? ((MouseEvent)e).getModifiers() : 0;
JOptionPane.showMessageDialog( this, "Closed tab '" + tabbedPane.getTitleAt( tabIndex ) + "'." JOptionPane.showMessageDialog( this, "Closed tab '" + tabbedPane2.getTitleAt( tabIndex ) + "'."
+ "\n\n(modifiers: " + MouseEvent.getMouseModifiersText( modifiers ) + ")", + "\n\n(modifiers: " + MouseEvent.getMouseModifiersText( modifiers ) + ")",
"Tab Closed", JOptionPane.PLAIN_MESSAGE ); "Tab Closed", JOptionPane.PLAIN_MESSAGE );
} ); } );
}
} }
} }
private void secondTabClosableChanged() { private void secondTabClosableChanged() {
Boolean value = secondTabClosableCheckBox.getValue(); Boolean closable = secondTabClosableCheckBox.getValue();
for( JTabbedPane tabbedPane : allTabbedPanes ) { for( FlatTabbedPane tabbedPane : allTabbedPanes ) {
if( tabbedPane.getTabCount() > 1 ) { if( tabbedPane.getTabCount() > 1 ) {
Component c = tabbedPane.getComponentAt( 1 ); if( closable != null )
((JComponent)c).putClientProperty( TABBED_PANE_TAB_CLOSABLE, value ); tabbedPane.setTabClosable( 1, closable );
else {
JComponent c = (JComponent) tabbedPane.getComponentAt( 1 );
c.putClientProperty( TABBED_PANE_TAB_CLOSABLE, null );
}
} }
} }
} }
private void tabAreaInsetsChanged() { private void tabAreaInsetsChanged() {
Insets insets = tabAreaInsetsCheckBox.isSelected() ? new Insets( 5, 5, 10, 10 ) : null; Insets insets = tabAreaInsetsCheckBox.isSelected() ? new Insets( 5, 5, 10, 10 ) : null;
putTabbedPanesClientProperty( TABBED_PANE_TAB_AREA_INSETS, insets ); for( FlatTabbedPane tabbedPane : allTabbedPanes )
tabbedPane.setTabAreaInsets( insets );
} }
private void smallerTabHeightChanged() { private void smallerTabHeightChanged() {
Integer tabHeight = smallerTabHeightCheckBox.isSelected() ? 26 : null; int tabHeight = smallerTabHeightCheckBox.isSelected() ? 26 : -1;
putTabbedPanesClientProperty( TABBED_PANE_TAB_HEIGHT, tabHeight ); for( FlatTabbedPane tabbedPane : allTabbedPanes )
tabbedPane.setTabHeight( tabHeight );
} }
private void smallerInsetsChanged() { private void smallerInsetsChanged() {
Insets insets = smallerInsetsCheckBox.isSelected() ? new Insets( 2, 2, 2, 2 ) : null; Insets insets = smallerInsetsCheckBox.isSelected() ? new Insets( 2, 2, 2, 2 ) : null;
putTabbedPanesClientProperty( TABBED_PANE_TAB_INSETS, insets ); for( FlatTabbedPane tabbedPane : allTabbedPanes )
tabbedPane.setTabInsets( insets );
} }
private void secondTabWiderChanged() { private void secondTabWiderChanged() {
Insets insets = secondTabWiderCheckBox.isSelected() ? new Insets( 4, 20, 4, 20 ) : null; Insets insets = secondTabWiderCheckBox.isSelected() ? new Insets( 4, 20, 4, 20 ) : null;
for( JTabbedPane tabbedPane : allTabbedPanes ) { for( FlatTabbedPane tabbedPane : allTabbedPanes ) {
if( tabbedPane.getTabCount() > 1 ) { if( tabbedPane.getTabCount() > 1 )
Component c = tabbedPane.getComponentAt( 1 ); tabbedPane.setTabInsets( 1, insets );
((JComponent)c).putClientProperty( TABBED_PANE_TAB_INSETS, insets );
}
} }
} }
private void minimumTabWidthChanged() { private void minimumTabWidthChanged() {
Integer minimumTabWidth = minimumTabWidthCheckBox.isSelected() ? 100 : null; int minimumTabWidth = minimumTabWidthCheckBox.isSelected() ? 100 : -1;
putTabbedPanesClientProperty( TABBED_PANE_MINIMUM_TAB_WIDTH, minimumTabWidth ); for( FlatTabbedPane tabbedPane : allTabbedPanes )
tabbedPane.setMinimumTabWidth( minimumTabWidth );
} }
private void maximumTabWidthChanged() { private void maximumTabWidthChanged() {
Integer maximumTabWidth = maximumTabWidthCheckBox.isSelected() ? 60 : null; int maximumTabWidth = maximumTabWidthCheckBox.isSelected() ? 60 : -1;
putTabbedPanesClientProperty( TABBED_PANE_MAXIMUM_TAB_WIDTH, maximumTabWidth ); for( FlatTabbedPane tabbedPane : allTabbedPanes )
tabbedPane.setMaximumTabWidth( maximumTabWidth );
} }
private void initComponents() { private void initComponents() {
@@ -424,10 +426,10 @@ public class FlatContainerTest
JPanel panel13 = new JPanel(); JPanel panel13 = new JPanel();
JLabel label4 = new JLabel(); JLabel label4 = new JLabel();
JLabel tabbedPaneLabel = new JLabel(); JLabel tabbedPaneLabel = new JLabel();
tabbedPane1 = new JTabbedPane(); tabbedPane1 = new FlatTabbedPane();
tabbedPane3 = new JTabbedPane(); tabbedPane3 = new FlatTabbedPane();
tabbedPane2 = new JTabbedPane(); tabbedPane2 = new FlatTabbedPane();
tabbedPane4 = new JTabbedPane(); tabbedPane4 = new FlatTabbedPane();
FlatTestFrame.NoRightToLeftPanel tabbedPaneControlPanel = new FlatTestFrame.NoRightToLeftPanel(); FlatTestFrame.NoRightToLeftPanel tabbedPaneControlPanel = new FlatTestFrame.NoRightToLeftPanel();
tabScrollCheckBox = new JCheckBox(); tabScrollCheckBox = new JCheckBox();
JLabel tabCountLabel = new JLabel(); JLabel tabCountLabel = new JLabel();
@@ -436,24 +438,24 @@ public class FlatContainerTest
htmlTabsCheckBox = new JCheckBox(); htmlTabsCheckBox = new JCheckBox();
multiLineTabsCheckBox = new JCheckBox(); multiLineTabsCheckBox = new JCheckBox();
JLabel tabsPopupPolicyLabel = new JLabel(); JLabel tabsPopupPolicyLabel = new JLabel();
tabsPopupPolicyField = new JComboBox<>(); tabsPopupPolicyField = new FlatTestEnumComboBox<>();
tabBackForegroundCheckBox = new JCheckBox(); tabBackForegroundCheckBox = new JCheckBox();
JLabel scrollButtonsPolicyLabel = new JLabel(); JLabel scrollButtonsPolicyLabel = new JLabel();
scrollButtonsPolicyField = new JComboBox<>(); scrollButtonsPolicyField = new FlatTestEnumComboBox<>();
tabIconsCheckBox = new JCheckBox(); tabIconsCheckBox = new JCheckBox();
tabIconSizeSpinner = new JSpinner(); tabIconSizeSpinner = new JSpinner();
iconPlacementField = new JComboBox<>(); iconPlacementField = new FlatTestEnumComboBox<>();
JLabel scrollButtonsPlacementLabel = new JLabel(); JLabel scrollButtonsPlacementLabel = new JLabel();
scrollButtonsPlacementField = new JComboBox<>(); scrollButtonsPlacementField = new FlatTestEnumComboBox<>();
tabsClosableCheckBox = new JCheckBox(); tabsClosableCheckBox = new JCheckBox();
JLabel tabPlacementLabel = new JLabel(); JLabel tabPlacementLabel = new JLabel();
tabPlacementField = new JComboBox<>(); tabPlacementField = new FlatTestEnumComboBox<>();
secondTabClosableCheckBox = new TriStateCheckBox(); secondTabClosableCheckBox = new TriStateCheckBox();
JLabel tabAreaAlignmentLabel = new JLabel(); JLabel tabAreaAlignmentLabel = new JLabel();
tabAreaAlignmentField = new JComboBox<>(); tabAreaAlignmentField = new FlatTestEnumComboBox<>();
tabAlignmentField = new JComboBox<>(); tabAlignmentField = new FlatTestEnumComboBox<>();
JLabel tabWidthModeLabel = new JLabel(); JLabel tabWidthModeLabel = new JLabel();
tabWidthModeField = new JComboBox<>(); tabWidthModeField = new FlatTestEnumComboBox<>();
leadingComponentCheckBox = new JCheckBox(); leadingComponentCheckBox = new JCheckBox();
customBorderCheckBox = new JCheckBox(); customBorderCheckBox = new JCheckBox();
tabAreaInsetsCheckBox = new JCheckBox(); tabAreaInsetsCheckBox = new JCheckBox();
@@ -623,11 +625,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabsPopupPolicyLabel, "cell 0 1"); tabbedPaneControlPanel.add(tabsPopupPolicyLabel, "cell 0 1");
//---- tabsPopupPolicyField ---- //---- tabsPopupPolicyField ----
tabsPopupPolicyField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"asNeeded",
"never"
}));
tabsPopupPolicyField.addActionListener(e -> tabsPopupPolicyChanged()); tabsPopupPolicyField.addActionListener(e -> tabsPopupPolicyChanged());
tabbedPaneControlPanel.add(tabsPopupPolicyField, "cell 1 1"); tabbedPaneControlPanel.add(tabsPopupPolicyField, "cell 1 1");
@@ -641,12 +638,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(scrollButtonsPolicyLabel, "cell 0 2"); tabbedPaneControlPanel.add(scrollButtonsPolicyLabel, "cell 0 2");
//---- scrollButtonsPolicyField ---- //---- scrollButtonsPolicyField ----
scrollButtonsPolicyField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"asNeededSingle",
"asNeeded",
"never"
}));
scrollButtonsPolicyField.addActionListener(e -> scrollButtonsPolicyChanged()); scrollButtonsPolicyField.addActionListener(e -> scrollButtonsPolicyChanged());
tabbedPaneControlPanel.add(scrollButtonsPolicyField, "cell 1 2"); tabbedPaneControlPanel.add(scrollButtonsPolicyField, "cell 1 2");
@@ -662,12 +653,7 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabIconSizeSpinner, "cell 2 2"); tabbedPaneControlPanel.add(tabIconSizeSpinner, "cell 2 2");
//---- iconPlacementField ---- //---- iconPlacementField ----
iconPlacementField.setModel(new DefaultComboBoxModel<>(new String[] { iconPlacementField.setEnabled(false);
"leading",
"trailing",
"top",
"bottom"
}));
iconPlacementField.addActionListener(e -> iconPlacementChanged()); iconPlacementField.addActionListener(e -> iconPlacementChanged());
tabbedPaneControlPanel.add(iconPlacementField, "cell 2 2"); tabbedPaneControlPanel.add(iconPlacementField, "cell 2 2");
@@ -676,11 +662,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(scrollButtonsPlacementLabel, "cell 0 3"); tabbedPaneControlPanel.add(scrollButtonsPlacementLabel, "cell 0 3");
//---- scrollButtonsPlacementField ---- //---- scrollButtonsPlacementField ----
scrollButtonsPlacementField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"both",
"trailing"
}));
scrollButtonsPlacementField.addActionListener(e -> scrollButtonsPlacementChanged()); scrollButtonsPlacementField.addActionListener(e -> scrollButtonsPlacementChanged());
tabbedPaneControlPanel.add(scrollButtonsPlacementField, "cell 1 3"); tabbedPaneControlPanel.add(scrollButtonsPlacementField, "cell 1 3");
@@ -694,13 +675,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabPlacementLabel, "cell 0 4"); tabbedPaneControlPanel.add(tabPlacementLabel, "cell 0 4");
//---- tabPlacementField ---- //---- tabPlacementField ----
tabPlacementField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"top",
"bottom",
"left",
"right"
}));
tabPlacementField.addActionListener(e -> tabPlacementChanged()); tabPlacementField.addActionListener(e -> tabPlacementChanged());
tabbedPaneControlPanel.add(tabPlacementField, "cell 1 4"); tabbedPaneControlPanel.add(tabPlacementField, "cell 1 4");
@@ -714,23 +688,10 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabAreaAlignmentLabel, "cell 0 5"); tabbedPaneControlPanel.add(tabAreaAlignmentLabel, "cell 0 5");
//---- tabAreaAlignmentField ---- //---- tabAreaAlignmentField ----
tabAreaAlignmentField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"leading",
"trailing",
"center",
"fill"
}));
tabAreaAlignmentField.addActionListener(e -> tabAreaAlignmentChanged()); tabAreaAlignmentField.addActionListener(e -> tabAreaAlignmentChanged());
tabbedPaneControlPanel.add(tabAreaAlignmentField, "cell 1 5"); tabbedPaneControlPanel.add(tabAreaAlignmentField, "cell 1 5");
//---- tabAlignmentField ---- //---- tabAlignmentField ----
tabAlignmentField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"leading",
"trailing",
"center"
}));
tabAlignmentField.addActionListener(e -> tabAlignmentChanged()); tabAlignmentField.addActionListener(e -> tabAlignmentChanged());
tabbedPaneControlPanel.add(tabAlignmentField, "cell 1 5"); tabbedPaneControlPanel.add(tabAlignmentField, "cell 1 5");
@@ -739,12 +700,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabWidthModeLabel, "cell 2 5"); tabbedPaneControlPanel.add(tabWidthModeLabel, "cell 2 5");
//---- tabWidthModeField ---- //---- tabWidthModeField ----
tabWidthModeField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"preferred",
"equal",
"compact"
}));
tabWidthModeField.addActionListener(e -> tabWidthModeChanged()); tabWidthModeField.addActionListener(e -> tabWidthModeChanged());
tabbedPaneControlPanel.add(tabWidthModeField, "cell 2 5"); tabbedPaneControlPanel.add(tabWidthModeField, "cell 2 5");
@@ -818,32 +773,32 @@ public class FlatContainerTest
add(panel9, "cell 0 0"); add(panel9, "cell 0 0");
// JFormDesigner - End of component initialization //GEN-END:initComponents // JFormDesigner - End of component initialization //GEN-END:initComponents
allTabbedPanes = new JTabbedPane[] { tabbedPane1, tabbedPane2, tabbedPane3, tabbedPane4 }; allTabbedPanes = new FlatTabbedPane[] { tabbedPane1, tabbedPane2, tabbedPane3, tabbedPane4 };
} }
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JTabbedPane tabbedPane1; private FlatTabbedPane tabbedPane1;
private JTabbedPane tabbedPane3; private FlatTabbedPane tabbedPane3;
private JTabbedPane tabbedPane2; private FlatTabbedPane tabbedPane2;
private JTabbedPane tabbedPane4; private FlatTabbedPane tabbedPane4;
private JCheckBox tabScrollCheckBox; private JCheckBox tabScrollCheckBox;
private JSpinner tabCountSpinner; private JSpinner tabCountSpinner;
private JCheckBox customTabsCheckBox; private JCheckBox customTabsCheckBox;
private JCheckBox htmlTabsCheckBox; private JCheckBox htmlTabsCheckBox;
private JCheckBox multiLineTabsCheckBox; private JCheckBox multiLineTabsCheckBox;
private JComboBox<String> tabsPopupPolicyField; private FlatTestEnumComboBox<TabsPopupPolicy> tabsPopupPolicyField;
private JCheckBox tabBackForegroundCheckBox; private JCheckBox tabBackForegroundCheckBox;
private JComboBox<String> scrollButtonsPolicyField; private FlatTestEnumComboBox<ScrollButtonsPolicy> scrollButtonsPolicyField;
private JCheckBox tabIconsCheckBox; private JCheckBox tabIconsCheckBox;
private JSpinner tabIconSizeSpinner; private JSpinner tabIconSizeSpinner;
private JComboBox<String> iconPlacementField; private FlatTestEnumComboBox<TabIconPlacement> iconPlacementField;
private JComboBox<String> scrollButtonsPlacementField; private FlatTestEnumComboBox<ScrollButtonsPlacement> scrollButtonsPlacementField;
private JCheckBox tabsClosableCheckBox; private JCheckBox tabsClosableCheckBox;
private JComboBox<String> tabPlacementField; private FlatTestEnumComboBox<TabPlacement> tabPlacementField;
private TriStateCheckBox secondTabClosableCheckBox; private TriStateCheckBox secondTabClosableCheckBox;
private JComboBox<String> tabAreaAlignmentField; private FlatTestEnumComboBox<TabAreaAlignment> tabAreaAlignmentField;
private JComboBox<String> tabAlignmentField; private FlatTestEnumComboBox<TabAlignment> tabAlignmentField;
private JComboBox<String> tabWidthModeField; private FlatTestEnumComboBox<TabWidthMode> tabWidthModeField;
private JCheckBox leadingComponentCheckBox; private JCheckBox leadingComponentCheckBox;
private JCheckBox customBorderCheckBox; private JCheckBox customBorderCheckBox;
private JCheckBox tabAreaInsetsCheckBox; private JCheckBox tabAreaInsetsCheckBox;
@@ -859,7 +814,37 @@ public class FlatContainerTest
private JCheckBox hideTabAreaWithOneTabCheckBox; private JCheckBox hideTabAreaWithOneTabCheckBox;
// JFormDesigner - End of variables declaration //GEN-END:variables // JFormDesigner - End of variables declaration //GEN-END:variables
private JTabbedPane[] allTabbedPanes; private FlatTabbedPane[] allTabbedPanes;
//---- enum TabPlacement --------------------------------------------------
enum TabPlacement {
top( SwingConstants.TOP ),
bottom( SwingConstants.BOTTOM ),
left( SwingConstants.LEFT ),
right( SwingConstants.RIGHT );
public final int value;
TabPlacement( int value ) {
this.value = value;
}
};
//---- enum TabIconPlacement ----------------------------------------------
enum TabIconPlacement {
leading( SwingConstants.LEADING ),
trailing( SwingConstants.TRAILING ),
top( SwingConstants.TOP ),
bottom( SwingConstants.BOTTOM );
public final int value;
TabIconPlacement( int value ) {
this.value = value;
}
};
//---- class Tab1Panel ---------------------------------------------------- //---- class Tab1Panel ----------------------------------------------------

View File

@@ -91,7 +91,7 @@ new FormModel {
"gridX": 1 "gridX": 1
"gridY": 5 "gridY": 5
} ) } )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { add( new FormContainer( "com.formdev.flatlaf.extras.components.FlatTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabbedPane1" name: "tabbedPane1"
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
@@ -100,7 +100,7 @@ new FormModel {
"gridX": 1 "gridX": 1
"gridY": 7 "gridY": 7
} ) } )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { add( new FormContainer( "com.formdev.flatlaf.extras.components.FlatTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabbedPane3" name: "tabbedPane3"
"tabPlacement": 2 "tabPlacement": 2
auxiliary() { auxiliary() {
@@ -110,7 +110,7 @@ new FormModel {
"gridX": 3 "gridX": 3
"gridY": 7 "gridY": 7
} ) } )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { add( new FormContainer( "com.formdev.flatlaf.extras.components.FlatTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabbedPane2" name: "tabbedPane2"
"tabPlacement": 3 "tabPlacement": 3
auxiliary() { auxiliary() {
@@ -119,7 +119,7 @@ new FormModel {
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridY": 9 "gridY": 9
} ) } )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { add( new FormContainer( "com.formdev.flatlaf.extras.components.FlatTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabbedPane4" name: "tabbedPane4"
"tabPlacement": 4 "tabPlacement": 4
auxiliary() { auxiliary() {
@@ -202,17 +202,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1" "value": "cell 0 1"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabsPopupPolicyField" name: "tabsPopupPolicyField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "asNeeded" )
addElement( "never" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "TabsPopupPolicy"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabsPopupPolicyChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabsPopupPolicyChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -234,18 +228,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2" "value": "cell 0 2"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "scrollButtonsPolicyField" name: "scrollButtonsPolicyField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "asNeededSingle" )
addElement( "asNeeded" )
addElement( "never" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "ScrollButtonsPolicy"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scrollButtonsPolicyChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scrollButtonsPolicyChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -280,18 +267,12 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2" "value": "cell 2 2"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "iconPlacementField" name: "iconPlacementField"
"model": new javax.swing.DefaultComboBoxModel { "enabled": false
selectedItem: "leading"
addElement( "leading" )
addElement( "trailing" )
addElement( "top" )
addElement( "bottom" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "TabIconPlacement"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "iconPlacementChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "iconPlacementChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -303,17 +284,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3" "value": "cell 0 3"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "scrollButtonsPlacementField" name: "scrollButtonsPlacementField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "both" )
addElement( "trailing" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "ScrollButtonsPlacement"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scrollButtonsPlacementChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scrollButtonsPlacementChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -335,19 +310,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4" "value": "cell 0 4"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabPlacementField" name: "tabPlacementField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "top" )
addElement( "bottom" )
addElement( "left" )
addElement( "right" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "TabPlacement"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabPlacementChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabPlacementChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -369,36 +336,21 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5" "value": "cell 0 5"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabAreaAlignmentField" name: "tabAreaAlignmentField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "leading" )
addElement( "trailing" )
addElement( "center" )
addElement( "fill" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "TabAreaAlignment"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAreaAlignmentChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAreaAlignmentChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5" "value": "cell 1 5"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabAlignmentField" name: "tabAlignmentField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "leading" )
addElement( "trailing" )
addElement( "center" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "TabAlignment"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAlignmentChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAlignmentChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -410,18 +362,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 5" "value": "cell 2 5"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabWidthModeField" name: "tabWidthModeField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "preferred" )
addElement( "equal" )
addElement( "compact" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "TabWidthMode"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabWidthModeChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabWidthModeChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {