diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java index 4cbdb775..73a8cdc5 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java @@ -264,7 +264,7 @@ public interface FlatClientProperties 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. *
* Component {@link javax.swing.JTabbedPane}
* Value type {@link java.lang.Boolean}
@@ -349,7 +349,7 @@ public interface FlatClientProperties
* Specifies the callback that is invoked when a tab close button is clicked.
* The callback is responsible for closing the tab.
*
- * 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: *
{@code
* myTabbedPane.putClientProperty( "JTabbedPane.tabCloseCallback",
* (IntConsumer) tabIndex -> {
@@ -357,7 +357,7 @@ public interface FlatClientProperties
* } );
* }
* Or use a {@link java.util.function.BiConsumer}<javax.swing.JTabbedPane, Integer>
- * that received the tabbed pane and the tab index as parameters:
+ * that receives the tabbed pane and the tab index as parameters:
* {@code
* myTabbedPane.putClientProperty( "JTabbedPane.tabCloseCallback",
* (BiConsumer) (tabbedPane, tabIndex) -> {
diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatComponentExtension.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatComponentExtension.java
index 139ea768..29f753c3 100644
--- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatComponentExtension.java
+++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatComponentExtension.java
@@ -17,6 +17,7 @@
package com.formdev.flatlaf.extras.components;
import java.awt.Color;
+import java.awt.Insets;
import javax.swing.JComponent;
import javax.swing.UIManager;
@@ -70,6 +71,11 @@ public interface FlatComponentExtension
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 getClientPropertyEnumString( Object key, Class enumType,
String defaultValueKey, T defaultValue )
diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTabbedPane.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTabbedPane.java
new file mode 100644
index 00000000..7cd70ce2
--- /dev/null
+++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTabbedPane.java
@@ -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.
+ *
+ * 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.
+ *
+ * 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)}.
+ *
+ * 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)}.
+ *
+ * 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 getTabCloseCallback() {
+ return (BiConsumer) 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.
+ *
+ * Use a {@link java.util.function.BiConsumer}<javax.swing.JTabbedPane, Integer>
+ * that receives the tabbed pane and the tab index as parameters:
+ *
{@code
+ * myTabbedPane.setTabCloseCallback( (tabbedPane, tabIndex) -> {
+ * // close tab here
+ * } );
+ * }
+ * 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.
+ * {@code
+ * AWTEvent e = EventQueue.getCurrentEvent();
+ * boolean shift = (e instanceof MouseEvent) ? ((MouseEvent)e).isShiftDown() : false;
+ * }
+ */
+ public void setTabCloseCallback( BiConsumer 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 getTabCloseCallback( int tabIndex ) {
+ JComponent c = (JComponent) getComponentAt( tabIndex );
+ return (BiConsumer) 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 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).
+ *
+ * Allowed Values are:
+ *
+ * - {@link SwingConstants#LEADING} (default)
+ *
- {@link SwingConstants#TRAILING}
+ *
- {@link SwingConstants#TOP}
+ *
- {@link SwingConstants#BOTTOM}
+ *
+ */
+ 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.
+ *
+ * For top and bottom tab placement, the layed out component size will be
+ * the preferred component width and the tab area height.
+ * 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.
+ *
+ * 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.
+ * 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 );
+ }
+}
diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.java
index 4fdc86af..d1d063e5 100644
--- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.java
+++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.java
@@ -19,11 +19,12 @@ package com.formdev.flatlaf.testing;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.*;
import java.awt.event.MouseEvent;
-import java.util.function.BiConsumer;
import javax.swing.*;
import javax.swing.border.*;
import com.formdev.flatlaf.FlatLaf;
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.util.ScaledImageIcon;
import com.jgoodies.forms.layout.*;
@@ -46,11 +47,21 @@ public class FlatContainerTest
public FlatContainerTest() {
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();
tabsClosableCheckBox.setSelected( true );
tabsClosableChanged();
- putTabbedPanesClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT, "Close" );
+ for( FlatTabbedPane tabbedPane : allTabbedPanes )
+ tabbedPane.setTabCloseToolTipText( "Close" );
tabScrollCheckBox.setSelected( true );
tabScrollChanged();
@@ -79,7 +90,7 @@ public class FlatContainerTest
}
private void hideTabAreaWithOneTabChanged() {
- boolean hideTabAreaWithOneTab = hideTabAreaWithOneTabCheckBox.isSelected();
+ Boolean hideTabAreaWithOneTab = hideTabAreaWithOneTabCheckBox.isSelected() ? true : null;
putTabbedPanesClientProperty( TABBED_PANE_HIDE_TAB_AREA_WITH_ONE_TAB, hideTabAreaWithOneTab );
}
@@ -158,6 +169,7 @@ public class FlatContainerTest
setTabIcons( tabbedPane );
tabIconSizeSpinner.setEnabled( tabIconsCheckBox.isSelected() );
+ iconPlacementField.setEnabled( tabIconsCheckBox.isSelected() );
}
private void setTabIcons( JTabbedPane tabbedPane ) {
@@ -182,14 +194,10 @@ public class FlatContainerTest
}
private void iconPlacementChanged() {
- Object iconPlacement = null;
- switch( (String) iconPlacementField.getSelectedItem() ) {
- case "leading": iconPlacement = SwingConstants.LEADING; break;
- case "trailing": iconPlacement = SwingConstants.TRAILING; break;
- case "top": iconPlacement = SwingConstants.TOP; break;
- case "bottom": iconPlacement = SwingConstants.BOTTOM; break;
- }
- putTabbedPanesClientProperty( TABBED_PANE_TAB_ICON_PLACEMENT, iconPlacement );
+ TabIconPlacement value = iconPlacementField.getSelectedValue();
+ int iconPlacement = (value != null) ? value.value : -1;
+ for( FlatTabbedPane tabbedPane : allTabbedPanes )
+ tabbedPane.setTabIconPlacement( iconPlacement );
}
private void customBorderChanged() {
@@ -252,13 +260,8 @@ public class FlatContainerTest
}
private void tabPlacementChanged() {
- int tabPlacement = -1;
- switch( (String) tabPlacementField.getSelectedItem() ) {
- case "top": tabPlacement = SwingConstants.TOP; break;
- case "bottom": tabPlacement = SwingConstants.BOTTOM; break;
- case "left": tabPlacement = SwingConstants.LEFT; break;
- case "right": tabPlacement = SwingConstants.RIGHT; break;
- }
+ TabPlacement value = tabPlacementField.getSelectedValue();
+ int tabPlacement = (value != null) ? value.value : -1;
tabbedPane1.setTabPlacement( (tabPlacement >= 0) ? tabPlacement : SwingConstants.TOP );
tabbedPane2.setTabPlacement( (tabPlacement >= 0) ? tabPlacement : SwingConstants.BOTTOM );
@@ -267,49 +270,39 @@ public class FlatContainerTest
}
private void tabsPopupPolicyChanged() {
- String value = (String) tabsPopupPolicyField.getSelectedItem();
- if( "default".equals( value ) )
- value = null;
- putTabbedPanesClientProperty( TABBED_PANE_TABS_POPUP_POLICY, value );
+ TabsPopupPolicy value = tabsPopupPolicyField.getSelectedValue();
+ for( FlatTabbedPane tabbedPane : allTabbedPanes )
+ tabbedPane.setTabsPopupPolicy( value );
}
private void scrollButtonsPolicyChanged() {
- String value = (String) scrollButtonsPolicyField.getSelectedItem();
- if( "default".equals( value ) )
- value = null;
- putTabbedPanesClientProperty( TABBED_PANE_SCROLL_BUTTONS_POLICY, value );
+ ScrollButtonsPolicy value = scrollButtonsPolicyField.getSelectedValue();
+ for( FlatTabbedPane tabbedPane : allTabbedPanes )
+ tabbedPane.setScrollButtonsPolicy( value );
}
private void scrollButtonsPlacementChanged() {
- String value = (String) scrollButtonsPlacementField.getSelectedItem();
- if( "default".equals( value ) )
- value = null;
- putTabbedPanesClientProperty( TABBED_PANE_SCROLL_BUTTONS_PLACEMENT, value );
+ ScrollButtonsPlacement value = scrollButtonsPlacementField.getSelectedValue();
+ for( FlatTabbedPane tabbedPane : allTabbedPanes )
+ tabbedPane.setScrollButtonsPlacement( value );
}
private void tabAreaAlignmentChanged() {
- String value = (String) tabAreaAlignmentField.getSelectedItem();
- if( "default".equals( value ) )
- value = null;
- putTabbedPanesClientProperty( TABBED_PANE_TAB_AREA_ALIGNMENT, value );
+ TabAreaAlignment value = tabAreaAlignmentField.getSelectedValue();
+ for( FlatTabbedPane tabbedPane : allTabbedPanes )
+ tabbedPane.setTabAreaAlignment( 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 );
+ TabAlignment value = tabAlignmentField.getSelectedValue();
+ for( FlatTabbedPane tabbedPane : allTabbedPanes )
+ tabbedPane.setTabAlignment( value );
}
private void tabWidthModeChanged() {
- String value = (String) tabWidthModeField.getSelectedItem();
- if( "default".equals( value ) )
- value = null;
- putTabbedPanesClientProperty( TABBED_PANE_TAB_WIDTH_MODE, value );
+ TabWidthMode value = tabWidthModeField.getSelectedValue();
+ for( FlatTabbedPane tabbedPane : allTabbedPanes )
+ tabbedPane.setTabWidthMode( value );
}
private void tabBackForegroundChanged() {
@@ -349,65 +342,74 @@ public class FlatContainerTest
private void tabsClosableChanged() {
boolean closable = tabsClosableCheckBox.isSelected();
- putTabbedPanesClientProperty( TABBED_PANE_TAB_CLOSABLE, closable ? true : null );
+ for( FlatTabbedPane tabbedPane : allTabbedPanes )
+ tabbedPane.setTabsClosable( closable );
if( closable ) {
- putTabbedPanesClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK,
- (BiConsumer) (tabbedPane, tabIndex) -> {
+ for( FlatTabbedPane tabbedPane : allTabbedPanes ) {
+ tabbedPane.setTabCloseCallback( (tabbedPane2, tabIndex) -> {
AWTEvent e = EventQueue.getCurrentEvent();
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 ) + ")",
"Tab Closed", JOptionPane.PLAIN_MESSAGE );
} );
+ }
}
}
private void secondTabClosableChanged() {
- Boolean value = secondTabClosableCheckBox.getValue();
+ Boolean closable = secondTabClosableCheckBox.getValue();
- for( JTabbedPane tabbedPane : allTabbedPanes ) {
+ for( FlatTabbedPane tabbedPane : allTabbedPanes ) {
if( tabbedPane.getTabCount() > 1 ) {
- Component c = tabbedPane.getComponentAt( 1 );
- ((JComponent)c).putClientProperty( TABBED_PANE_TAB_CLOSABLE, value );
+ if( closable != null )
+ tabbedPane.setTabClosable( 1, closable );
+ else {
+ JComponent c = (JComponent) tabbedPane.getComponentAt( 1 );
+ c.putClientProperty( TABBED_PANE_TAB_CLOSABLE, null );
+ }
}
}
}
private void tabAreaInsetsChanged() {
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() {
- Integer tabHeight = smallerTabHeightCheckBox.isSelected() ? 26 : null;
- putTabbedPanesClientProperty( TABBED_PANE_TAB_HEIGHT, tabHeight );
+ int tabHeight = smallerTabHeightCheckBox.isSelected() ? 26 : -1;
+ for( FlatTabbedPane tabbedPane : allTabbedPanes )
+ tabbedPane.setTabHeight( tabHeight );
}
private void smallerInsetsChanged() {
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() {
Insets insets = secondTabWiderCheckBox.isSelected() ? new Insets( 4, 20, 4, 20 ) : null;
- for( JTabbedPane tabbedPane : allTabbedPanes ) {
- if( tabbedPane.getTabCount() > 1 ) {
- Component c = tabbedPane.getComponentAt( 1 );
- ((JComponent)c).putClientProperty( TABBED_PANE_TAB_INSETS, insets );
- }
+ for( FlatTabbedPane tabbedPane : allTabbedPanes ) {
+ if( tabbedPane.getTabCount() > 1 )
+ tabbedPane.setTabInsets( 1, insets );
}
}
private void minimumTabWidthChanged() {
- Integer minimumTabWidth = minimumTabWidthCheckBox.isSelected() ? 100 : null;
- putTabbedPanesClientProperty( TABBED_PANE_MINIMUM_TAB_WIDTH, minimumTabWidth );
+ int minimumTabWidth = minimumTabWidthCheckBox.isSelected() ? 100 : -1;
+ for( FlatTabbedPane tabbedPane : allTabbedPanes )
+ tabbedPane.setMinimumTabWidth( minimumTabWidth );
}
private void maximumTabWidthChanged() {
- Integer maximumTabWidth = maximumTabWidthCheckBox.isSelected() ? 60 : null;
- putTabbedPanesClientProperty( TABBED_PANE_MAXIMUM_TAB_WIDTH, maximumTabWidth );
+ int maximumTabWidth = maximumTabWidthCheckBox.isSelected() ? 60 : -1;
+ for( FlatTabbedPane tabbedPane : allTabbedPanes )
+ tabbedPane.setMaximumTabWidth( maximumTabWidth );
}
private void initComponents() {
@@ -424,10 +426,10 @@ public class FlatContainerTest
JPanel panel13 = new JPanel();
JLabel label4 = new JLabel();
JLabel tabbedPaneLabel = new JLabel();
- tabbedPane1 = new JTabbedPane();
- tabbedPane3 = new JTabbedPane();
- tabbedPane2 = new JTabbedPane();
- tabbedPane4 = new JTabbedPane();
+ tabbedPane1 = new FlatTabbedPane();
+ tabbedPane3 = new FlatTabbedPane();
+ tabbedPane2 = new FlatTabbedPane();
+ tabbedPane4 = new FlatTabbedPane();
FlatTestFrame.NoRightToLeftPanel tabbedPaneControlPanel = new FlatTestFrame.NoRightToLeftPanel();
tabScrollCheckBox = new JCheckBox();
JLabel tabCountLabel = new JLabel();
@@ -436,24 +438,24 @@ public class FlatContainerTest
htmlTabsCheckBox = new JCheckBox();
multiLineTabsCheckBox = new JCheckBox();
JLabel tabsPopupPolicyLabel = new JLabel();
- tabsPopupPolicyField = new JComboBox<>();
+ tabsPopupPolicyField = new FlatTestEnumComboBox<>();
tabBackForegroundCheckBox = new JCheckBox();
JLabel scrollButtonsPolicyLabel = new JLabel();
- scrollButtonsPolicyField = new JComboBox<>();
+ scrollButtonsPolicyField = new FlatTestEnumComboBox<>();
tabIconsCheckBox = new JCheckBox();
tabIconSizeSpinner = new JSpinner();
- iconPlacementField = new JComboBox<>();
+ iconPlacementField = new FlatTestEnumComboBox<>();
JLabel scrollButtonsPlacementLabel = new JLabel();
- scrollButtonsPlacementField = new JComboBox<>();
+ scrollButtonsPlacementField = new FlatTestEnumComboBox<>();
tabsClosableCheckBox = new JCheckBox();
JLabel tabPlacementLabel = new JLabel();
- tabPlacementField = new JComboBox<>();
+ tabPlacementField = new FlatTestEnumComboBox<>();
secondTabClosableCheckBox = new TriStateCheckBox();
JLabel tabAreaAlignmentLabel = new JLabel();
- tabAreaAlignmentField = new JComboBox<>();
- tabAlignmentField = new JComboBox<>();
+ tabAreaAlignmentField = new FlatTestEnumComboBox<>();
+ tabAlignmentField = new FlatTestEnumComboBox<>();
JLabel tabWidthModeLabel = new JLabel();
- tabWidthModeField = new JComboBox<>();
+ tabWidthModeField = new FlatTestEnumComboBox<>();
leadingComponentCheckBox = new JCheckBox();
customBorderCheckBox = new JCheckBox();
tabAreaInsetsCheckBox = new JCheckBox();
@@ -623,11 +625,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabsPopupPolicyLabel, "cell 0 1");
//---- tabsPopupPolicyField ----
- tabsPopupPolicyField.setModel(new DefaultComboBoxModel<>(new String[] {
- "default",
- "asNeeded",
- "never"
- }));
tabsPopupPolicyField.addActionListener(e -> tabsPopupPolicyChanged());
tabbedPaneControlPanel.add(tabsPopupPolicyField, "cell 1 1");
@@ -641,12 +638,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(scrollButtonsPolicyLabel, "cell 0 2");
//---- scrollButtonsPolicyField ----
- scrollButtonsPolicyField.setModel(new DefaultComboBoxModel<>(new String[] {
- "default",
- "asNeededSingle",
- "asNeeded",
- "never"
- }));
scrollButtonsPolicyField.addActionListener(e -> scrollButtonsPolicyChanged());
tabbedPaneControlPanel.add(scrollButtonsPolicyField, "cell 1 2");
@@ -662,12 +653,7 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabIconSizeSpinner, "cell 2 2");
//---- iconPlacementField ----
- iconPlacementField.setModel(new DefaultComboBoxModel<>(new String[] {
- "leading",
- "trailing",
- "top",
- "bottom"
- }));
+ iconPlacementField.setEnabled(false);
iconPlacementField.addActionListener(e -> iconPlacementChanged());
tabbedPaneControlPanel.add(iconPlacementField, "cell 2 2");
@@ -676,11 +662,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(scrollButtonsPlacementLabel, "cell 0 3");
//---- scrollButtonsPlacementField ----
- scrollButtonsPlacementField.setModel(new DefaultComboBoxModel<>(new String[] {
- "default",
- "both",
- "trailing"
- }));
scrollButtonsPlacementField.addActionListener(e -> scrollButtonsPlacementChanged());
tabbedPaneControlPanel.add(scrollButtonsPlacementField, "cell 1 3");
@@ -694,13 +675,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabPlacementLabel, "cell 0 4");
//---- tabPlacementField ----
- tabPlacementField.setModel(new DefaultComboBoxModel<>(new String[] {
- "default",
- "top",
- "bottom",
- "left",
- "right"
- }));
tabPlacementField.addActionListener(e -> tabPlacementChanged());
tabbedPaneControlPanel.add(tabPlacementField, "cell 1 4");
@@ -714,23 +688,10 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabAreaAlignmentLabel, "cell 0 5");
//---- tabAreaAlignmentField ----
- tabAreaAlignmentField.setModel(new DefaultComboBoxModel<>(new String[] {
- "default",
- "leading",
- "trailing",
- "center",
- "fill"
- }));
tabAreaAlignmentField.addActionListener(e -> tabAreaAlignmentChanged());
tabbedPaneControlPanel.add(tabAreaAlignmentField, "cell 1 5");
//---- tabAlignmentField ----
- tabAlignmentField.setModel(new DefaultComboBoxModel<>(new String[] {
- "default",
- "leading",
- "trailing",
- "center"
- }));
tabAlignmentField.addActionListener(e -> tabAlignmentChanged());
tabbedPaneControlPanel.add(tabAlignmentField, "cell 1 5");
@@ -739,12 +700,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabWidthModeLabel, "cell 2 5");
//---- tabWidthModeField ----
- tabWidthModeField.setModel(new DefaultComboBoxModel<>(new String[] {
- "default",
- "preferred",
- "equal",
- "compact"
- }));
tabWidthModeField.addActionListener(e -> tabWidthModeChanged());
tabbedPaneControlPanel.add(tabWidthModeField, "cell 2 5");
@@ -818,32 +773,32 @@ public class FlatContainerTest
add(panel9, "cell 0 0");
// 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
- private JTabbedPane tabbedPane1;
- private JTabbedPane tabbedPane3;
- private JTabbedPane tabbedPane2;
- private JTabbedPane tabbedPane4;
+ private FlatTabbedPane tabbedPane1;
+ private FlatTabbedPane tabbedPane3;
+ private FlatTabbedPane tabbedPane2;
+ private FlatTabbedPane tabbedPane4;
private JCheckBox tabScrollCheckBox;
private JSpinner tabCountSpinner;
private JCheckBox customTabsCheckBox;
private JCheckBox htmlTabsCheckBox;
private JCheckBox multiLineTabsCheckBox;
- private JComboBox tabsPopupPolicyField;
+ private FlatTestEnumComboBox tabsPopupPolicyField;
private JCheckBox tabBackForegroundCheckBox;
- private JComboBox scrollButtonsPolicyField;
+ private FlatTestEnumComboBox scrollButtonsPolicyField;
private JCheckBox tabIconsCheckBox;
private JSpinner tabIconSizeSpinner;
- private JComboBox iconPlacementField;
- private JComboBox scrollButtonsPlacementField;
+ private FlatTestEnumComboBox iconPlacementField;
+ private FlatTestEnumComboBox scrollButtonsPlacementField;
private JCheckBox tabsClosableCheckBox;
- private JComboBox tabPlacementField;
+ private FlatTestEnumComboBox tabPlacementField;
private TriStateCheckBox secondTabClosableCheckBox;
- private JComboBox tabAreaAlignmentField;
- private JComboBox tabAlignmentField;
- private JComboBox tabWidthModeField;
+ private FlatTestEnumComboBox tabAreaAlignmentField;
+ private FlatTestEnumComboBox tabAlignmentField;
+ private FlatTestEnumComboBox tabWidthModeField;
private JCheckBox leadingComponentCheckBox;
private JCheckBox customBorderCheckBox;
private JCheckBox tabAreaInsetsCheckBox;
@@ -859,7 +814,37 @@ public class FlatContainerTest
private JCheckBox hideTabAreaWithOneTabCheckBox;
// 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 ----------------------------------------------------
diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.jfd
index 205708ed..1034387c 100644
--- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.jfd
+++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.jfd
@@ -91,7 +91,7 @@ new FormModel {
"gridX": 1
"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"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
@@ -100,7 +100,7 @@ new FormModel {
"gridX": 1
"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"
"tabPlacement": 2
auxiliary() {
@@ -110,7 +110,7 @@ new FormModel {
"gridX": 3
"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"
"tabPlacement": 3
auxiliary() {
@@ -119,7 +119,7 @@ new FormModel {
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"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"
"tabPlacement": 4
auxiliary() {
@@ -202,17 +202,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
- add( new FormComponent( "javax.swing.JComboBox" ) {
+ add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabsPopupPolicyField"
- "model": new javax.swing.DefaultComboBoxModel {
- selectedItem: "default"
- addElement( "default" )
- addElement( "asNeeded" )
- addElement( "never" )
- }
auxiliary() {
"JavaCodeGenerator.variableLocal": false
- "JavaCodeGenerator.typeParameters": "String"
+ "JavaCodeGenerator.typeParameters": "TabsPopupPolicy"
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabsPopupPolicyChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -234,18 +228,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
- add( new FormComponent( "javax.swing.JComboBox" ) {
+ add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "scrollButtonsPolicyField"
- "model": new javax.swing.DefaultComboBoxModel {
- selectedItem: "default"
- addElement( "default" )
- addElement( "asNeededSingle" )
- addElement( "asNeeded" )
- addElement( "never" )
- }
auxiliary() {
"JavaCodeGenerator.variableLocal": false
- "JavaCodeGenerator.typeParameters": "String"
+ "JavaCodeGenerator.typeParameters": "ScrollButtonsPolicy"
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scrollButtonsPolicyChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -280,18 +267,12 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2"
} )
- add( new FormComponent( "javax.swing.JComboBox" ) {
+ add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "iconPlacementField"
- "model": new javax.swing.DefaultComboBoxModel {
- selectedItem: "leading"
- addElement( "leading" )
- addElement( "trailing" )
- addElement( "top" )
- addElement( "bottom" )
- }
+ "enabled": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
- "JavaCodeGenerator.typeParameters": "String"
+ "JavaCodeGenerator.typeParameters": "TabIconPlacement"
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "iconPlacementChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -303,17 +284,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
- add( new FormComponent( "javax.swing.JComboBox" ) {
+ add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "scrollButtonsPlacementField"
- "model": new javax.swing.DefaultComboBoxModel {
- selectedItem: "default"
- addElement( "default" )
- addElement( "both" )
- addElement( "trailing" )
- }
auxiliary() {
"JavaCodeGenerator.variableLocal": false
- "JavaCodeGenerator.typeParameters": "String"
+ "JavaCodeGenerator.typeParameters": "ScrollButtonsPlacement"
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scrollButtonsPlacementChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -335,19 +310,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
- add( new FormComponent( "javax.swing.JComboBox" ) {
+ add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabPlacementField"
- "model": new javax.swing.DefaultComboBoxModel {
- selectedItem: "default"
- addElement( "default" )
- addElement( "top" )
- addElement( "bottom" )
- addElement( "left" )
- addElement( "right" )
- }
auxiliary() {
"JavaCodeGenerator.variableLocal": false
- "JavaCodeGenerator.typeParameters": "String"
+ "JavaCodeGenerator.typeParameters": "TabPlacement"
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabPlacementChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -369,36 +336,21 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
- add( new FormComponent( "javax.swing.JComboBox" ) {
+ add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabAreaAlignmentField"
- "model": new javax.swing.DefaultComboBoxModel {
- selectedItem: "default"
- addElement( "default" )
- addElement( "leading" )
- addElement( "trailing" )
- addElement( "center" )
- addElement( "fill" )
- }
auxiliary() {
"JavaCodeGenerator.variableLocal": false
- "JavaCodeGenerator.typeParameters": "String"
+ "JavaCodeGenerator.typeParameters": "TabAreaAlignment"
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAreaAlignmentChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5"
} )
- add( new FormComponent( "javax.swing.JComboBox" ) {
+ add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabAlignmentField"
- "model": new javax.swing.DefaultComboBoxModel {
- selectedItem: "default"
- addElement( "default" )
- addElement( "leading" )
- addElement( "trailing" )
- addElement( "center" )
- }
auxiliary() {
"JavaCodeGenerator.variableLocal": false
- "JavaCodeGenerator.typeParameters": "String"
+ "JavaCodeGenerator.typeParameters": "TabAlignment"
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAlignmentChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -410,18 +362,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 5"
} )
- add( new FormComponent( "javax.swing.JComboBox" ) {
+ add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabWidthModeField"
- "model": new javax.swing.DefaultComboBoxModel {
- selectedItem: "default"
- addElement( "default" )
- addElement( "preferred" )
- addElement( "equal" )
- addElement( "compact" )
- }
auxiliary() {
"JavaCodeGenerator.variableLocal": false
- "JavaCodeGenerator.typeParameters": "String"
+ "JavaCodeGenerator.typeParameters": "TabWidthMode"
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabWidthModeChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {