diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.java index beaeb830..5e4bed57 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.java +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.java @@ -16,13 +16,15 @@ package com.formdev.flatlaf.demo; -import static com.formdev.flatlaf.FlatClientProperties.TABBED_PANE_HAS_FULL_BORDER; -import static com.formdev.flatlaf.FlatClientProperties.TABBED_PANE_SHOW_CONTENT_SEPARATOR; -import static com.formdev.flatlaf.FlatClientProperties.TABBED_PANE_SHOW_TAB_SEPARATORS; +import static com.formdev.flatlaf.FlatClientProperties.*; import java.awt.*; +import java.awt.event.MouseEvent; +import java.util.function.BiConsumer; +import java.util.function.Consumer; import javax.swing.*; import javax.swing.border.*; -import com.jgoodies.forms.layout.*; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.formdev.flatlaf.icons.FlatTabbedPaneCloseIcon; import net.miginfocom.swing.*; /** @@ -34,95 +36,42 @@ class TabsPanel TabsPanel() { initComponents(); - addInitialTabs( tabbedPane1, tabbedPane2, tabbedPane3, tabbedPane4 ); + initTabPlacementTabs( tabPlacementTabbedPane ); + + initScrollLayoutTabs( scrollLayoutTabbedPane ); + initWrapLayoutTabs( wrapLayoutTabbedPane ); + + initClosableTabs( closableTabsTabbedPane ); + + initCustomComponentsTabs( customComponentsTabbedPane ); + + initMinimumTabWidth( minimumTabWidthTabbedPane ); + initMaximumTabWidth( maximumTabWidthTabbedPane ); + + initTabIconPlacement( iconTopTabbedPane, SwingConstants.TOP ); + initTabIconPlacement( iconBottomTabbedPane, SwingConstants.BOTTOM ); + initTabIconPlacement( iconLeadingTabbedPane, SwingConstants.LEADING ); + initTabIconPlacement( iconTrailingTabbedPane, SwingConstants.TRAILING ); + + initTabAreaAlignment( alignLeadingTabbedPane, TABBED_PANE_TAB_AREA_ALIGN_LEADING ); + initTabAreaAlignment( alignCenterTabbedPane, TABBED_PANE_TAB_AREA_ALIGN_CENTER ); + initTabAreaAlignment( alignTrailingTabbedPane, TABBED_PANE_TAB_AREA_ALIGN_TRAILING ); + initTabAreaAlignment( alignFillTabbedPane, TABBED_PANE_TAB_AREA_ALIGN_FILL ); + + initTabWidthMode( widthPreferredTabbedPane, TABBED_PANE_TAB_WIDTH_MODE_PREFERRED ); + initTabWidthMode( widthEqualTabbedPane, TABBED_PANE_TAB_WIDTH_MODE_EQUAL ); + initTabWidthMode( widthCompactTabbedPane, TABBED_PANE_TAB_WIDTH_MODE_COMPACT ); } - private void tabScrollChanged() { - int tabLayoutPolicy = tabScrollCheckBox.isSelected() ? JTabbedPane.SCROLL_TAB_LAYOUT : JTabbedPane.WRAP_TAB_LAYOUT; - tabbedPane1.setTabLayoutPolicy( tabLayoutPolicy ); - tabbedPane2.setTabLayoutPolicy( tabLayoutPolicy ); - tabbedPane3.setTabLayoutPolicy( tabLayoutPolicy ); - tabbedPane4.setTabLayoutPolicy( tabLayoutPolicy ); + private void initTabPlacementTabs( JTabbedPane tabbedPane ) { + addTab( tabbedPane, "Tab 1", "tab content 1" ); - if( !autoMoreTabs && tabScrollCheckBox.isSelected() && !moreTabsCheckBox.isSelected() ) { - moreTabsCheckBox.setSelected( true ); - moreTabsChanged(); - autoMoreTabs = true; - } else if( autoMoreTabs && !tabScrollCheckBox.isSelected() && moreTabsCheckBox.isSelected() ) { - moreTabsCheckBox.setSelected( false ); - moreTabsChanged(); - autoMoreTabs = false; - } - } + JComponent tab2 = createTab( "tab content 2" ); + tab2.setBorder( new LineBorder( Color.magenta ) ); + tabbedPane.addTab( "Second Tab", tab2 ); - private boolean autoMoreTabs; - - private void showTabSeparatorsChanged() { - Boolean showTabSeparators = showTabSeparatorsCheckBox.isSelected() ? true : null; - putTabbedPanesClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators ); - } - - private void hideContentSeparatorChanged() { - Boolean showContentSeparator = hideContentSeparatorCheckBox.isSelected() ? false : null; - putTabbedPanesClientProperty( TABBED_PANE_SHOW_CONTENT_SEPARATOR, showContentSeparator ); - } - - private void hasFullBorderChanged() { - Boolean hasFullBorder = hasFullBorderCheckBox.isSelected() ? true : null; - putTabbedPanesClientProperty( TABBED_PANE_HAS_FULL_BORDER, hasFullBorder ); - } - - private void putTabbedPanesClientProperty( String key, Object value ) { - tabbedPane1.putClientProperty( key, value ); - tabbedPane2.putClientProperty( key, value ); - tabbedPane3.putClientProperty( key, value ); - tabbedPane4.putClientProperty( key, value ); - } - - private void moreTabsChanged() { - boolean moreTabs = moreTabsCheckBox.isSelected(); - addRemoveMoreTabs( tabbedPane1, moreTabs ); - addRemoveMoreTabs( tabbedPane2, moreTabs ); - addRemoveMoreTabs( tabbedPane3, moreTabs ); - addRemoveMoreTabs( tabbedPane4, moreTabs ); - - autoMoreTabs = false; - } - - private void addRemoveMoreTabs( JTabbedPane tabbedPane, boolean add ) { - if( add ) { - addTab( tabbedPane, "Tab 4", "tab content 4" ); - addTab( tabbedPane, "Tab 5", "tab content 5" ); - addTab( tabbedPane, "Tab 6", "tab content 6" ); - addTab( tabbedPane, "Tab 7", "tab content 7" ); - addTab( tabbedPane, "Tab 8", "tab content 8" ); - } else { - int tabCount = tabbedPane.getTabCount(); - if( tabCount > 3 ) { - for( int i = 0; i < 5; i++ ) - tabbedPane.removeTabAt( tabbedPane.getTabCount() - 1 ); - } - } - } - - private void addInitialTabs( JTabbedPane... tabbedPanes ) { - for( JTabbedPane tabbedPane : tabbedPanes ) { - String placement = "unknown"; - switch( tabbedPane.getTabPlacement() ) { - case JTabbedPane.TOP: placement = "TOP"; break; - case JTabbedPane.BOTTOM: placement = "BOTTOM"; break; - case JTabbedPane.LEFT: placement = "LEFT"; break; - case JTabbedPane.RIGHT: placement = "RIGHT"; break; - } - addTab( tabbedPane, "Tab 1", "
" + placement + "
tab placement
" ); - - JComponent tab2 = createTab( "tab content 2" ); - tab2.setBorder( new LineBorder( Color.magenta ) ); - tabbedPane.addTab( "Second Tab", tab2 ); - - addTab( tabbedPane, "Disabled", "tab content 3" ); - tabbedPane.setEnabledAt( 2, false ); - } + addTab( tabbedPane, "Disabled", "tab content 3" ); + tabbedPane.setEnabledAt( 2, false ); } private void addTab( JTabbedPane tabbedPane, String title, String text ) { @@ -138,114 +87,729 @@ class TabsPanel return tab; } + private void tabPlacementChanged() { + int tabPlacement = JTabbedPane.TOP; + if( bottomPlacementButton.isSelected() ) + tabPlacement = JTabbedPane.BOTTOM; + else if( leftPlacementButton.isSelected() ) + tabPlacement = JTabbedPane.LEFT; + else if( rightPlacementButton.isSelected() ) + tabPlacement = JTabbedPane.RIGHT; + + tabPlacementTabbedPane.setTabPlacement( tabPlacement ); + } + + private void scrollChanged() { + boolean scroll = scrollButton.isSelected(); + tabPlacementTabbedPane.setTabLayoutPolicy( scroll ? JTabbedPane.SCROLL_TAB_LAYOUT : JTabbedPane.WRAP_TAB_LAYOUT ); + + int extraTabCount = 7; + if( scroll ) { + int tabCount = tabPlacementTabbedPane.getTabCount(); + for( int i = tabCount + 1; i <= tabCount + extraTabCount; i++ ) + addTab( tabPlacementTabbedPane, "Tab " + i, "tab content " + i ); + } else { + for( int i = 0; i < extraTabCount; i++ ) + tabPlacementTabbedPane.removeTabAt( tabPlacementTabbedPane.getTabCount() - 1 ); + } + } + + private void borderChanged() { + Boolean hasFullBorder = borderButton.isSelected() ? true : null; + tabPlacementTabbedPane.putClientProperty( TABBED_PANE_HAS_FULL_BORDER, hasFullBorder ); + } + + private void initScrollLayoutTabs( JTabbedPane tabbedPane ) { + tabbedPane.setTabLayoutPolicy( JTabbedPane.SCROLL_TAB_LAYOUT ); + addDefaultTabsNoContent( tabbedPane, 9 ); + } + + private void initWrapLayoutTabs( JTabbedPane tabbedPane ) { + tabbedPane.setTabLayoutPolicy( JTabbedPane.WRAP_TAB_LAYOUT ); + addDefaultTabsNoContent( tabbedPane, 9 ); + + wrapLayoutTabbedPane.setVisible( false ); + wrapLayoutNoteLabel.setVisible( false ); + } + + private void tabLayoutChanged() { + boolean scroll = scrollTabLayoutButton.isSelected(); + + scrollLayoutTabbedPane.setVisible( scroll ); + scrollLayoutNoteLabel.setVisible( scroll ); + wrapLayoutTabbedPane.setVisible( !scroll ); + wrapLayoutNoteLabel.setVisible( !scroll ); + } + + private void initClosableTabs( JTabbedPane tabbedPane ) { + tabbedPane.putClientProperty( TABBED_PANE_TAB_CLOSABLE, true ); + tabbedPane.putClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT, "Close" ); + tabbedPane.putClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK, + (BiConsumer) (tabPane, tabIndex) -> { + AWTEvent e = EventQueue.getCurrentEvent(); + int modifiers = (e instanceof MouseEvent) ? ((MouseEvent)e).getModifiers() : 0; + JOptionPane.showMessageDialog( this, "Closed tab '" + tabPane.getTitleAt( tabIndex ) + "'." + + "\n\n(modifiers: " + MouseEvent.getMouseModifiersText( modifiers ) + ")", + "Tab Closed", JOptionPane.PLAIN_MESSAGE ); + } ); + + addDefaultTabsNoContent( tabbedPane, 3 ); + } + + private void initCustomComponentsTabs( JTabbedPane tabbedPane ) { + addDefaultTabsNoContent( tabbedPane, 3 ); + customComponentsChanged(); + } + + private void customComponentsChanged() { + JComponent leading = null; + JComponent trailing = null; + if( leadingComponentButton.isSelected() ) { + leading = new JLabel( "Leading" ); + leading.setOpaque( true ); + leading.setBackground( new Color( UIManager.getColor( "Objects.Green" ).getRGB() ) ); + leading.setForeground( Color.black ); + leading.setBorder( new EmptyBorder( 4, 4, 4, 4 ) ); + } + if( trailingComponentButton.isSelected() ) { + trailing = new JLabel( "Trailing" ); + trailing.setOpaque( true ); + trailing.setBackground( new Color( UIManager.getColor( "Objects.Purple" ).getRGB() ) ); + trailing.setForeground( Color.black ); + trailing.setBorder( new EmptyBorder( 4, 4, 4, 4 ) ); + } + customComponentsTabbedPane.putClientProperty( TABBED_PANE_LEADING_COMPONENT, leading ); + customComponentsTabbedPane.putClientProperty( TABBED_PANE_TRAILING_COMPONENT, trailing ); + } + + private void addDefaultTabsNoContent( JTabbedPane tabbedPane, int count ) { + tabbedPane.addTab( "Tab 1", null ); + tabbedPane.addTab( "Second Tab", null ); + if( count >= 3 ) + tabbedPane.addTab( "3rd Tab", null ); + + for( int i = 4; i <= count; i++ ) + tabbedPane.addTab( "Tab " + i, null ); + } + + private void closeButtonStyleChanged() { + // WARNING: + // Do not use this trick to style individual tabbed panes in own code. + // Instead use one styling for all tabbed panes in your application. + if( circleCloseButton.isSelected() ) { + UIManager.put( "TabbedPane.closeArc", 999 ); + UIManager.put( "TabbedPane.closeCrossFilledSize", 5.5f ); + UIManager.put( "TabbedPane.closeIcon", new FlatTabbedPaneCloseIcon() ); + closableTabsTabbedPane.updateUI(); + UIManager.put( "TabbedPane.closeArc", null ); + UIManager.put( "TabbedPane.closeCrossFilledSize", null ); + UIManager.put( "TabbedPane.closeIcon", null ); + } else if( redCrossCloseButton.isSelected() ) { + UIManager.put( "TabbedPane.closeHoverForeground", Color.red ); + UIManager.put( "TabbedPane.closePressedForeground", Color.red ); + UIManager.put( "TabbedPane.closeHoverBackground", new Color( 0, true ) ); + UIManager.put( "TabbedPane.closeIcon", new FlatTabbedPaneCloseIcon() ); + closableTabsTabbedPane.updateUI(); + UIManager.put( "TabbedPane.closeHoverForeground", null ); + UIManager.put( "TabbedPane.closePressedForeground", null ); + UIManager.put( "TabbedPane.closeHoverBackground", null ); + UIManager.put( "TabbedPane.closeIcon", null ); + } else + closableTabsTabbedPane.updateUI(); + } + + private void initTabIconPlacement( JTabbedPane tabbedPane, int iconPlacement ) { + boolean topOrBottom = (iconPlacement == SwingConstants.TOP || iconPlacement == SwingConstants.BOTTOM); + int iconSize = topOrBottom ? 24 : 16; + tabbedPane.putClientProperty( TABBED_PANE_TAB_ICON_PLACEMENT, iconPlacement ); + if( topOrBottom ) { + tabbedPane.putClientProperty( TABBED_PANE_TAB_AREA_ALIGNMENT, TABBED_PANE_TAB_AREA_ALIGN_FILL ); + tabbedPane.putClientProperty( TABBED_PANE_TAB_WIDTH_MODE, TABBED_PANE_TAB_WIDTH_MODE_EQUAL ); + } + tabbedPane.addTab( "Search", new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/search.svg", iconSize, iconSize ), null ); + tabbedPane.addTab( "Recents", new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/RecentlyUsed.svg", iconSize, iconSize ), null ); + if( topOrBottom ) + tabbedPane.addTab( "Favorites", new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/favorite.svg", iconSize, iconSize ), null ); + } + + private void initTabAreaAlignment( JTabbedPane tabbedPane, String tabAreaAlignment ) { + tabbedPane.putClientProperty( TABBED_PANE_TAB_AREA_ALIGNMENT, tabAreaAlignment ); + tabbedPane.addTab( "Search", null ); + tabbedPane.addTab( "Recents", null ); + } + + private void initTabWidthMode( JTabbedPane tabbedPane, String tabWidthMode ) { + tabbedPane.putClientProperty( TABBED_PANE_TAB_WIDTH_MODE, tabWidthMode ); + if( tabWidthMode.equals( TABBED_PANE_TAB_WIDTH_MODE_COMPACT ) ) { + tabbedPane.addTab( "Search", new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/search.svg", 16, 16 ), null ); + tabbedPane.addTab( "Recents", new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/RecentlyUsed.svg", 16, 16 ), null ); + tabbedPane.addTab( "Favorites", new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/favorite.svg", 16, 16 ), null ); + } else { + tabbedPane.addTab( "Short", null ); + tabbedPane.addTab( "Longer Title", null ); + } + } + + private void initMinimumTabWidth( JTabbedPane tabbedPane ) { + tabbedPane.putClientProperty( TABBED_PANE_MINIMUM_TAB_WIDTH, 80 ); + tabbedPane.addTab( "A", null ); + tabbedPane.addTab( "Very long title", null ); + } + + private void initMaximumTabWidth( JTabbedPane tabbedPane ) { + tabbedPane.putClientProperty( TABBED_PANE_MAXIMUM_TAB_WIDTH, 80 ); + tabbedPane.addTab( "Very long title", null ); + tabbedPane.addTab( "B", null ); + tabbedPane.addTab( "C", null ); + } + + private void showTabSeparatorsChanged() { + Boolean showTabSeparators = showTabSeparatorsCheckBox.isSelected() ? true : null; + putTabbedPanesClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators ); + } + + private void putTabbedPanesClientProperty( String key, Object value ) { + updateTabbedPanesRecur( this, tabbedPane -> tabbedPane.putClientProperty( key, value ) ); + } + + private void updateTabbedPanesRecur( Container container, Consumer action ) { + for( Component c : container.getComponents() ) { + if( c instanceof JTabbedPane ) { + JTabbedPane tabPane = (JTabbedPane)c; + action.accept( tabPane ); + } + + if( c instanceof Container ) + updateTabbedPanesRecur( (Container) c, action ); + } + } + private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents - JPanel panel9 = new JPanel(); - JLabel tabbedPaneLabel = new JLabel(); - tabbedPane1 = new JTabbedPane(); - tabbedPane3 = new JTabbedPane(); - tabbedPane2 = new JTabbedPane(); - tabbedPane4 = new JTabbedPane(); - JPanel panel14 = new JPanel(); - moreTabsCheckBox = new JCheckBox(); - tabScrollCheckBox = new JCheckBox(); + JPanel panel1 = new JPanel(); + JLabel tabPlacementLabel = new JLabel(); + tabPlacementToolBar = new JToolBar(); + topPlacementButton = new JToggleButton(); + bottomPlacementButton = new JToggleButton(); + leftPlacementButton = new JToggleButton(); + rightPlacementButton = new JToggleButton(); + scrollButton = new JToggleButton(); + borderButton = new JToggleButton(); + tabPlacementTabbedPane = new JTabbedPane(); + JLabel tabLayoutLabel = new JLabel(); + tabLayoutToolBar = new JToolBar(); + scrollTabLayoutButton = new JToggleButton(); + wrapTabLayoutButton = new JToggleButton(); + scrollLayoutNoteLabel = new JLabel(); + wrapLayoutNoteLabel = new JLabel(); + scrollLayoutTabbedPane = new JTabbedPane(); + wrapLayoutTabbedPane = new JTabbedPane(); + JLabel closableTabsLabel = new JLabel(); + closableTabsToolBar = new JToolBar(); + squareCloseButton = new JToggleButton(); + circleCloseButton = new JToggleButton(); + redCrossCloseButton = new JToggleButton(); + closableTabsTabbedPane = new JTabbedPane(); + JLabel tabAreaComponentsLabel = new JLabel(); + tabAreaComponentsToolBar = new JToolBar(); + leadingComponentButton = new JToggleButton(); + trailingComponentButton = new JToggleButton(); + customComponentsTabbedPane = new JTabbedPane(); + JPanel panel2 = new JPanel(); + JLabel tabIconPlacementLabel = new JLabel(); + JLabel tabIconPlacementNodeLabel = new JLabel(); + iconTopTabbedPane = new JTabbedPane(); + iconBottomTabbedPane = new JTabbedPane(); + iconLeadingTabbedPane = new JTabbedPane(); + iconTrailingTabbedPane = new JTabbedPane(); + JLabel tabAreaAlignmentLabel = new JLabel(); + JLabel tabAreaAlignmentNoteLabel = new JLabel(); + alignLeadingTabbedPane = new JTabbedPane(); + alignCenterTabbedPane = new JTabbedPane(); + alignTrailingTabbedPane = new JTabbedPane(); + alignFillTabbedPane = new JTabbedPane(); + JPanel panel3 = new JPanel(); + JLabel tabWidthModeLabel = new JLabel(); + JLabel tabWidthModeNoteLabel = new JLabel(); + widthPreferredTabbedPane = new JTabbedPane(); + widthEqualTabbedPane = new JTabbedPane(); + widthCompactTabbedPane = new JTabbedPane(); + JLabel minMaxTabWidthLabel = new JLabel(); + minimumTabWidthTabbedPane = new JTabbedPane(); + maximumTabWidthTabbedPane = new JTabbedPane(); + JPanel panel4 = new JPanel(); showTabSeparatorsCheckBox = new JCheckBox(); - hideContentSeparatorCheckBox = new JCheckBox(); - hasFullBorderCheckBox = new JCheckBox(); - CellConstraints cc = new CellConstraints(); //======== this ======== + setName("this"); setLayout(new MigLayout( "insets dialog,hidemode 3", // columns - "[grow,fill]", + "[grow,fill]para" + + "[fill]para" + + "[fill]", // rows - "[grow,fill]")); + "[grow,fill]" + + "[]")); - //======== panel9 ======== + //======== panel1 ======== { - panel9.setLayout(new FormLayout( - "70dlu:grow, $ugap, 70dlu:grow", - "pref, $lgap, 2*(fill:80dlu:grow, $ugap), pref")); + panel1.setName("panel1"); + panel1.setLayout(new MigLayout( + "insets 0,hidemode 3", + // columns + "[grow,fill]", + // rows + "[]" + + "[fill]para" + + "[]0" + + "[]" + + "[]para" + + "[]" + + "[]para" + + "[]" + + "[]")); - //---- tabbedPaneLabel ---- - tabbedPaneLabel.setText("JTabbedPane:"); - panel9.add(tabbedPaneLabel, cc.xy(1, 1)); - panel9.add(tabbedPane1, cc.xy(1, 3)); + //---- tabPlacementLabel ---- + tabPlacementLabel.setText("Tab placement"); + tabPlacementLabel.setFont(tabPlacementLabel.getFont().deriveFont(tabPlacementLabel.getFont().getSize() + 4f)); + tabPlacementLabel.setName("tabPlacementLabel"); + panel1.add(tabPlacementLabel, "cell 0 0"); - //======== tabbedPane3 ======== + //======== tabPlacementToolBar ======== { - tabbedPane3.setTabPlacement(SwingConstants.LEFT); - } - panel9.add(tabbedPane3, cc.xy(3, 3)); + tabPlacementToolBar.setFloatable(false); + tabPlacementToolBar.setBorder(BorderFactory.createEmptyBorder()); + tabPlacementToolBar.setName("tabPlacementToolBar"); - //======== tabbedPane2 ======== + //---- topPlacementButton ---- + topPlacementButton.setText("top"); + topPlacementButton.setSelected(true); + topPlacementButton.setFont(topPlacementButton.getFont().deriveFont(topPlacementButton.getFont().getSize() - 2f)); + topPlacementButton.setName("topPlacementButton"); + topPlacementButton.addActionListener(e -> tabPlacementChanged()); + tabPlacementToolBar.add(topPlacementButton); + + //---- bottomPlacementButton ---- + bottomPlacementButton.setText("bottom"); + bottomPlacementButton.setFont(bottomPlacementButton.getFont().deriveFont(bottomPlacementButton.getFont().getSize() - 2f)); + bottomPlacementButton.setName("bottomPlacementButton"); + bottomPlacementButton.addActionListener(e -> tabPlacementChanged()); + tabPlacementToolBar.add(bottomPlacementButton); + + //---- leftPlacementButton ---- + leftPlacementButton.setText("left"); + leftPlacementButton.setFont(leftPlacementButton.getFont().deriveFont(leftPlacementButton.getFont().getSize() - 2f)); + leftPlacementButton.setName("leftPlacementButton"); + leftPlacementButton.addActionListener(e -> tabPlacementChanged()); + tabPlacementToolBar.add(leftPlacementButton); + + //---- rightPlacementButton ---- + rightPlacementButton.setText("right"); + rightPlacementButton.setFont(rightPlacementButton.getFont().deriveFont(rightPlacementButton.getFont().getSize() - 2f)); + rightPlacementButton.setName("rightPlacementButton"); + rightPlacementButton.addActionListener(e -> tabPlacementChanged()); + tabPlacementToolBar.add(rightPlacementButton); + tabPlacementToolBar.addSeparator(); + + //---- scrollButton ---- + scrollButton.setText("scroll"); + scrollButton.setFont(scrollButton.getFont().deriveFont(scrollButton.getFont().getSize() - 2f)); + scrollButton.setName("scrollButton"); + scrollButton.addActionListener(e -> scrollChanged()); + tabPlacementToolBar.add(scrollButton); + + //---- borderButton ---- + borderButton.setText("border"); + borderButton.setFont(borderButton.getFont().deriveFont(borderButton.getFont().getSize() - 2f)); + borderButton.setName("borderButton"); + borderButton.addActionListener(e -> borderChanged()); + tabPlacementToolBar.add(borderButton); + } + panel1.add(tabPlacementToolBar, "cell 0 0,alignx right,growx 0"); + + //======== tabPlacementTabbedPane ======== { - tabbedPane2.setTabPlacement(SwingConstants.BOTTOM); + tabPlacementTabbedPane.setName("tabPlacementTabbedPane"); } - panel9.add(tabbedPane2, cc.xy(1, 5)); + panel1.add(tabPlacementTabbedPane, "cell 0 1,width 300:300,height 100:100"); - //======== tabbedPane4 ======== + //---- tabLayoutLabel ---- + tabLayoutLabel.setText("Tab layout"); + tabLayoutLabel.setFont(tabLayoutLabel.getFont().deriveFont(tabLayoutLabel.getFont().getSize() + 4f)); + tabLayoutLabel.setName("tabLayoutLabel"); + panel1.add(tabLayoutLabel, "cell 0 2"); + + //======== tabLayoutToolBar ======== { - tabbedPane4.setTabPlacement(SwingConstants.RIGHT); - } - panel9.add(tabbedPane4, cc.xy(3, 5)); + tabLayoutToolBar.setFloatable(false); + tabLayoutToolBar.setBorder(BorderFactory.createEmptyBorder()); + tabLayoutToolBar.setName("tabLayoutToolBar"); - //======== panel14 ======== + //---- scrollTabLayoutButton ---- + scrollTabLayoutButton.setText("scroll"); + scrollTabLayoutButton.setFont(scrollTabLayoutButton.getFont().deriveFont(scrollTabLayoutButton.getFont().getSize() - 2f)); + scrollTabLayoutButton.setSelected(true); + scrollTabLayoutButton.setName("scrollTabLayoutButton"); + scrollTabLayoutButton.addActionListener(e -> tabLayoutChanged()); + tabLayoutToolBar.add(scrollTabLayoutButton); + + //---- wrapTabLayoutButton ---- + wrapTabLayoutButton.setText("wrap"); + wrapTabLayoutButton.setFont(wrapTabLayoutButton.getFont().deriveFont(wrapTabLayoutButton.getFont().getSize() - 2f)); + wrapTabLayoutButton.setName("wrapTabLayoutButton"); + wrapTabLayoutButton.addActionListener(e -> tabLayoutChanged()); + tabLayoutToolBar.add(wrapTabLayoutButton); + } + panel1.add(tabLayoutToolBar, "cell 0 2,alignx right,growx 0"); + + //---- scrollLayoutNoteLabel ---- + scrollLayoutNoteLabel.setText("(use mouse wheel to scroll; arrow button shows hidden tabs)"); + scrollLayoutNoteLabel.setEnabled(false); + scrollLayoutNoteLabel.setFont(scrollLayoutNoteLabel.getFont().deriveFont(scrollLayoutNoteLabel.getFont().getSize() - 2f)); + scrollLayoutNoteLabel.setName("scrollLayoutNoteLabel"); + panel1.add(scrollLayoutNoteLabel, "cell 0 3"); + + //---- wrapLayoutNoteLabel ---- + wrapLayoutNoteLabel.setText("(probably better to use scroll layout?)"); + wrapLayoutNoteLabel.setEnabled(false); + wrapLayoutNoteLabel.setFont(wrapLayoutNoteLabel.getFont().deriveFont(wrapLayoutNoteLabel.getFont().getSize() - 2f)); + wrapLayoutNoteLabel.setName("wrapLayoutNoteLabel"); + panel1.add(wrapLayoutNoteLabel, "cell 0 3"); + + //======== scrollLayoutTabbedPane ======== { - panel14.setLayout(new MigLayout( - "insets 0,hidemode 3", - // columns - "[]" + - "[]" + - "[]" + - "[fill]" + - "[]", - // rows - "[center]")); - - //---- moreTabsCheckBox ---- - moreTabsCheckBox.setText("More tabs"); - moreTabsCheckBox.setMnemonic('M'); - moreTabsCheckBox.addActionListener(e -> moreTabsChanged()); - panel14.add(moreTabsCheckBox, "cell 0 0"); - - //---- tabScrollCheckBox ---- - tabScrollCheckBox.setText("Use scroll layout"); - tabScrollCheckBox.setMnemonic('S'); - tabScrollCheckBox.addActionListener(e -> tabScrollChanged()); - panel14.add(tabScrollCheckBox, "cell 1 0,alignx left,growx 0"); - - //---- showTabSeparatorsCheckBox ---- - showTabSeparatorsCheckBox.setText("Show tab separators"); - showTabSeparatorsCheckBox.addActionListener(e -> showTabSeparatorsChanged()); - panel14.add(showTabSeparatorsCheckBox, "cell 2 0"); - - //---- hideContentSeparatorCheckBox ---- - hideContentSeparatorCheckBox.setText("Hide content separator"); - hideContentSeparatorCheckBox.addActionListener(e -> hideContentSeparatorChanged()); - panel14.add(hideContentSeparatorCheckBox, "cell 3 0"); - - //---- hasFullBorderCheckBox ---- - hasFullBorderCheckBox.setText("Show content border"); - hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged()); - panel14.add(hasFullBorderCheckBox, "cell 4 0,alignx left,growx 0"); + scrollLayoutTabbedPane.setName("scrollLayoutTabbedPane"); } - panel9.add(panel14, cc.xywh(1, 7, 3, 1)); + panel1.add(scrollLayoutTabbedPane, "cell 0 4"); + + //======== wrapLayoutTabbedPane ======== + { + wrapLayoutTabbedPane.setName("wrapLayoutTabbedPane"); + } + panel1.add(wrapLayoutTabbedPane, "cell 0 4,width 100:100,height pref*2px"); + + //---- closableTabsLabel ---- + closableTabsLabel.setText("Closable tabs"); + closableTabsLabel.setFont(closableTabsLabel.getFont().deriveFont(closableTabsLabel.getFont().getSize() + 4f)); + closableTabsLabel.setName("closableTabsLabel"); + panel1.add(closableTabsLabel, "cell 0 5"); + + //======== closableTabsToolBar ======== + { + closableTabsToolBar.setFloatable(false); + closableTabsToolBar.setBorder(BorderFactory.createEmptyBorder()); + closableTabsToolBar.setName("closableTabsToolBar"); + + //---- squareCloseButton ---- + squareCloseButton.setText("square"); + squareCloseButton.setFont(squareCloseButton.getFont().deriveFont(squareCloseButton.getFont().getSize() - 2f)); + squareCloseButton.setSelected(true); + squareCloseButton.setName("squareCloseButton"); + squareCloseButton.addActionListener(e -> closeButtonStyleChanged()); + closableTabsToolBar.add(squareCloseButton); + + //---- circleCloseButton ---- + circleCloseButton.setText("circle"); + circleCloseButton.setFont(circleCloseButton.getFont().deriveFont(circleCloseButton.getFont().getSize() - 2f)); + circleCloseButton.setName("circleCloseButton"); + circleCloseButton.addActionListener(e -> closeButtonStyleChanged()); + closableTabsToolBar.add(circleCloseButton); + + //---- redCrossCloseButton ---- + redCrossCloseButton.setText("red cross"); + redCrossCloseButton.setFont(redCrossCloseButton.getFont().deriveFont(redCrossCloseButton.getFont().getSize() - 2f)); + redCrossCloseButton.setName("redCrossCloseButton"); + redCrossCloseButton.addActionListener(e -> closeButtonStyleChanged()); + closableTabsToolBar.add(redCrossCloseButton); + } + panel1.add(closableTabsToolBar, "cell 0 5,alignx right,growx 0"); + + //======== closableTabsTabbedPane ======== + { + closableTabsTabbedPane.setName("closableTabsTabbedPane"); + } + panel1.add(closableTabsTabbedPane, "cell 0 6"); + + //---- tabAreaComponentsLabel ---- + tabAreaComponentsLabel.setText("Custom tab area components"); + tabAreaComponentsLabel.setFont(tabAreaComponentsLabel.getFont().deriveFont(tabAreaComponentsLabel.getFont().getSize() + 4f)); + tabAreaComponentsLabel.setName("tabAreaComponentsLabel"); + panel1.add(tabAreaComponentsLabel, "cell 0 7"); + + //======== tabAreaComponentsToolBar ======== + { + tabAreaComponentsToolBar.setFloatable(false); + tabAreaComponentsToolBar.setBorder(BorderFactory.createEmptyBorder()); + tabAreaComponentsToolBar.setName("tabAreaComponentsToolBar"); + + //---- leadingComponentButton ---- + leadingComponentButton.setText("leading"); + leadingComponentButton.setFont(leadingComponentButton.getFont().deriveFont(leadingComponentButton.getFont().getSize() - 2f)); + leadingComponentButton.setSelected(true); + leadingComponentButton.setName("leadingComponentButton"); + leadingComponentButton.addActionListener(e -> customComponentsChanged()); + tabAreaComponentsToolBar.add(leadingComponentButton); + + //---- trailingComponentButton ---- + trailingComponentButton.setText("trailing"); + trailingComponentButton.setFont(trailingComponentButton.getFont().deriveFont(trailingComponentButton.getFont().getSize() - 2f)); + trailingComponentButton.setSelected(true); + trailingComponentButton.setName("trailingComponentButton"); + trailingComponentButton.addActionListener(e -> customComponentsChanged()); + tabAreaComponentsToolBar.add(trailingComponentButton); + } + panel1.add(tabAreaComponentsToolBar, "cell 0 7,alignx right,growx 0"); + + //======== customComponentsTabbedPane ======== + { + customComponentsTabbedPane.setName("customComponentsTabbedPane"); + } + panel1.add(customComponentsTabbedPane, "cell 0 8"); } - add(panel9, "cell 0 0"); + add(panel1, "cell 0 0"); + + //======== panel2 ======== + { + panel2.setName("panel2"); + panel2.setLayout(new MigLayout( + "insets 0,hidemode 3", + // columns + "[grow,fill]", + // rows + "[]0" + + "[]" + + "[fill]" + + "[center]" + + "[center]" + + "[center]para" + + "[center]0" + + "[]" + + "[center]" + + "[center]" + + "[center]" + + "[]")); + + //---- tabIconPlacementLabel ---- + tabIconPlacementLabel.setText("Tab icon placement"); + tabIconPlacementLabel.setFont(tabIconPlacementLabel.getFont().deriveFont(tabIconPlacementLabel.getFont().getSize() + 4f)); + tabIconPlacementLabel.setName("tabIconPlacementLabel"); + panel2.add(tabIconPlacementLabel, "cell 0 0"); + + //---- tabIconPlacementNodeLabel ---- + tabIconPlacementNodeLabel.setText("(top/bottom/leading/trailing)"); + tabIconPlacementNodeLabel.setEnabled(false); + tabIconPlacementNodeLabel.setFont(tabIconPlacementNodeLabel.getFont().deriveFont(tabIconPlacementNodeLabel.getFont().getSize() - 2f)); + tabIconPlacementNodeLabel.setName("tabIconPlacementNodeLabel"); + panel2.add(tabIconPlacementNodeLabel, "cell 0 1"); + + //======== iconTopTabbedPane ======== + { + iconTopTabbedPane.setName("iconTopTabbedPane"); + } + panel2.add(iconTopTabbedPane, "cell 0 2"); + + //======== iconBottomTabbedPane ======== + { + iconBottomTabbedPane.setName("iconBottomTabbedPane"); + } + panel2.add(iconBottomTabbedPane, "cell 0 3"); + + //======== iconLeadingTabbedPane ======== + { + iconLeadingTabbedPane.setName("iconLeadingTabbedPane"); + } + panel2.add(iconLeadingTabbedPane, "cell 0 4"); + + //======== iconTrailingTabbedPane ======== + { + iconTrailingTabbedPane.setName("iconTrailingTabbedPane"); + } + panel2.add(iconTrailingTabbedPane, "cell 0 5"); + + //---- tabAreaAlignmentLabel ---- + tabAreaAlignmentLabel.setText("Tab area alignment"); + tabAreaAlignmentLabel.setFont(tabAreaAlignmentLabel.getFont().deriveFont(tabAreaAlignmentLabel.getFont().getSize() + 4f)); + tabAreaAlignmentLabel.setName("tabAreaAlignmentLabel"); + panel2.add(tabAreaAlignmentLabel, "cell 0 6"); + + //---- tabAreaAlignmentNoteLabel ---- + tabAreaAlignmentNoteLabel.setText("(leading/center/trailing/fill)"); + tabAreaAlignmentNoteLabel.setEnabled(false); + tabAreaAlignmentNoteLabel.setFont(tabAreaAlignmentNoteLabel.getFont().deriveFont(tabAreaAlignmentNoteLabel.getFont().getSize() - 2f)); + tabAreaAlignmentNoteLabel.setName("tabAreaAlignmentNoteLabel"); + panel2.add(tabAreaAlignmentNoteLabel, "cell 0 7"); + + //======== alignLeadingTabbedPane ======== + { + alignLeadingTabbedPane.setName("alignLeadingTabbedPane"); + } + panel2.add(alignLeadingTabbedPane, "cell 0 8"); + + //======== alignCenterTabbedPane ======== + { + alignCenterTabbedPane.setName("alignCenterTabbedPane"); + } + panel2.add(alignCenterTabbedPane, "cell 0 9"); + + //======== alignTrailingTabbedPane ======== + { + alignTrailingTabbedPane.setName("alignTrailingTabbedPane"); + } + panel2.add(alignTrailingTabbedPane, "cell 0 10"); + + //======== alignFillTabbedPane ======== + { + alignFillTabbedPane.setName("alignFillTabbedPane"); + } + panel2.add(alignFillTabbedPane, "cell 0 11"); + } + add(panel2, "cell 1 0,growy"); + + //======== panel3 ======== + { + panel3.setName("panel3"); + panel3.setLayout(new MigLayout( + "insets 0,hidemode 3", + // columns + "[grow,fill]", + // rows + "[]0" + + "[]" + + "[]" + + "[]" + + "[]para" + + "[]" + + "[]" + + "[]")); + + //---- tabWidthModeLabel ---- + tabWidthModeLabel.setText("Tab width mode"); + tabWidthModeLabel.setFont(tabWidthModeLabel.getFont().deriveFont(tabWidthModeLabel.getFont().getSize() + 4f)); + tabWidthModeLabel.setName("tabWidthModeLabel"); + panel3.add(tabWidthModeLabel, "cell 0 0"); + + //---- tabWidthModeNoteLabel ---- + tabWidthModeNoteLabel.setText("(preferred/equal/compact)"); + tabWidthModeNoteLabel.setFont(tabWidthModeNoteLabel.getFont().deriveFont(tabWidthModeNoteLabel.getFont().getSize() - 2f)); + tabWidthModeNoteLabel.setEnabled(false); + tabWidthModeNoteLabel.setName("tabWidthModeNoteLabel"); + panel3.add(tabWidthModeNoteLabel, "cell 0 1"); + + //======== widthPreferredTabbedPane ======== + { + widthPreferredTabbedPane.setName("widthPreferredTabbedPane"); + } + panel3.add(widthPreferredTabbedPane, "cell 0 2"); + + //======== widthEqualTabbedPane ======== + { + widthEqualTabbedPane.setName("widthEqualTabbedPane"); + } + panel3.add(widthEqualTabbedPane, "cell 0 3"); + + //======== widthCompactTabbedPane ======== + { + widthCompactTabbedPane.setName("widthCompactTabbedPane"); + } + panel3.add(widthCompactTabbedPane, "cell 0 4"); + + //---- minMaxTabWidthLabel ---- + minMaxTabWidthLabel.setText("Minimum/maximum tab width"); + minMaxTabWidthLabel.setFont(minMaxTabWidthLabel.getFont().deriveFont(minMaxTabWidthLabel.getFont().getSize() + 4f)); + minMaxTabWidthLabel.setName("minMaxTabWidthLabel"); + panel3.add(minMaxTabWidthLabel, "cell 0 5"); + + //======== minimumTabWidthTabbedPane ======== + { + minimumTabWidthTabbedPane.setName("minimumTabWidthTabbedPane"); + } + panel3.add(minimumTabWidthTabbedPane, "cell 0 6"); + + //======== maximumTabWidthTabbedPane ======== + { + maximumTabWidthTabbedPane.setName("maximumTabWidthTabbedPane"); + } + panel3.add(maximumTabWidthTabbedPane, "cell 0 7"); + } + add(panel3, "cell 2 0"); + + //======== panel4 ======== + { + panel4.setName("panel4"); + panel4.setLayout(new MigLayout( + "insets 0,hidemode 3", + // columns + "[]", + // rows + "[center]")); + + //---- showTabSeparatorsCheckBox ---- + showTabSeparatorsCheckBox.setText("Show tab separators"); + showTabSeparatorsCheckBox.setName("showTabSeparatorsCheckBox"); + showTabSeparatorsCheckBox.addActionListener(e -> showTabSeparatorsChanged()); + panel4.add(showTabSeparatorsCheckBox, "cell 0 0"); + } + add(panel4, "cell 0 1 3 1"); + + //---- tabPlacementButtonGroup ---- + ButtonGroup tabPlacementButtonGroup = new ButtonGroup(); + tabPlacementButtonGroup.add(topPlacementButton); + tabPlacementButtonGroup.add(bottomPlacementButton); + tabPlacementButtonGroup.add(leftPlacementButton); + tabPlacementButtonGroup.add(rightPlacementButton); + + //---- buttonGroup2 ---- + ButtonGroup buttonGroup2 = new ButtonGroup(); + buttonGroup2.add(scrollTabLayoutButton); + buttonGroup2.add(wrapTabLayoutButton); + + //---- buttonGroup1 ---- + ButtonGroup buttonGroup1 = new ButtonGroup(); + buttonGroup1.add(squareCloseButton); + buttonGroup1.add(circleCloseButton); + buttonGroup1.add(redCrossCloseButton); // JFormDesigner - End of component initialization //GEN-END:initComponents } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables - private JTabbedPane tabbedPane1; - private JTabbedPane tabbedPane3; - private JTabbedPane tabbedPane2; - private JTabbedPane tabbedPane4; - private JCheckBox moreTabsCheckBox; - private JCheckBox tabScrollCheckBox; + private JToolBar tabPlacementToolBar; + private JToggleButton topPlacementButton; + private JToggleButton bottomPlacementButton; + private JToggleButton leftPlacementButton; + private JToggleButton rightPlacementButton; + private JToggleButton scrollButton; + private JToggleButton borderButton; + private JTabbedPane tabPlacementTabbedPane; + private JToolBar tabLayoutToolBar; + private JToggleButton scrollTabLayoutButton; + private JToggleButton wrapTabLayoutButton; + private JLabel scrollLayoutNoteLabel; + private JLabel wrapLayoutNoteLabel; + private JTabbedPane scrollLayoutTabbedPane; + private JTabbedPane wrapLayoutTabbedPane; + private JToolBar closableTabsToolBar; + private JToggleButton squareCloseButton; + private JToggleButton circleCloseButton; + private JToggleButton redCrossCloseButton; + private JTabbedPane closableTabsTabbedPane; + private JToolBar tabAreaComponentsToolBar; + private JToggleButton leadingComponentButton; + private JToggleButton trailingComponentButton; + private JTabbedPane customComponentsTabbedPane; + private JTabbedPane iconTopTabbedPane; + private JTabbedPane iconBottomTabbedPane; + private JTabbedPane iconLeadingTabbedPane; + private JTabbedPane iconTrailingTabbedPane; + private JTabbedPane alignLeadingTabbedPane; + private JTabbedPane alignCenterTabbedPane; + private JTabbedPane alignTrailingTabbedPane; + private JTabbedPane alignFillTabbedPane; + private JTabbedPane widthPreferredTabbedPane; + private JTabbedPane widthEqualTabbedPane; + private JTabbedPane widthCompactTabbedPane; + private JTabbedPane minimumTabWidthTabbedPane; + private JTabbedPane maximumTabWidthTabbedPane; private JCheckBox showTabSeparatorsCheckBox; - private JCheckBox hideContentSeparatorCheckBox; - private JCheckBox hasFullBorderCheckBox; // JFormDesigner - End of variables declaration //GEN-END:variables } diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.jfd b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.jfd index e1563ceb..57394cd2 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.jfd +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/TabsPanel.jfd @@ -3,132 +3,431 @@ JFDML JFormDesigner: "7.0.2.0.298" Java: "15" encoding: "UTF-8" new FormModel { contentType: "form/swing" root: new FormRoot { - auxiliary() { - "JavaCodeGenerator.defaultVariableLocal": true - } + "$setComponentNames": true add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets dialog,hidemode 3" - "$columnConstraints": "[grow,fill]" - "$rowConstraints": "[grow,fill]" + "$columnConstraints": "[grow,fill]para[fill]para[fill]" + "$rowConstraints": "[grow,fill][]" } ) { name: "this" - add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class com.jgoodies.forms.layout.FormLayout ) { - "$columnSpecs": "70dlu:grow, unrelgap, 70dlu:grow" - "$rowSpecs": "pref, linegap, fill:80dlu:grow, unrelgap, fill:80dlu:grow, unrelgap, pref" + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "insets 0,hidemode 3" + "$columnConstraints": "[grow,fill]" + "$rowConstraints": "[][fill]para[]0[][]para[][]para[][]" } ) { - name: "panel9" + name: "panel1" + auxiliary() { + "JavaCodeGenerator.variableLocal": true + } add( new FormComponent( "javax.swing.JLabel" ) { - name: "tabbedPaneLabel" - "text": "JTabbedPane:" - }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { - "gridX": 1 + name: "tabPlacementLabel" + "text": "Tab placement" + "font": new com.jformdesigner.model.SwingDerivedFont( null, 0, 4, false ) + auxiliary() { + "JavaCodeGenerator.variableLocal": true + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { + name: "tabPlacementToolBar" + "floatable": false + "border": new javax.swing.border.EmptyBorder( 0, 0, 0, 0 ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "topPlacementButton" + "text": "top" + "selected": true + "$buttonGroup": new FormReference( "tabPlacementButtonGroup" ) + "font": &SwingDerivedFont0 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabPlacementChanged", false ) ) + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "bottomPlacementButton" + "text": "bottom" + "$buttonGroup": new FormReference( "tabPlacementButtonGroup" ) + "font": #SwingDerivedFont0 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabPlacementChanged", false ) ) + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "leftPlacementButton" + "text": "left" + "$buttonGroup": new FormReference( "tabPlacementButtonGroup" ) + "font": #SwingDerivedFont0 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabPlacementChanged", false ) ) + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "rightPlacementButton" + "text": "right" + "$buttonGroup": new FormReference( "tabPlacementButtonGroup" ) + "font": #SwingDerivedFont0 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabPlacementChanged", false ) ) + } ) + add( new FormComponent( "javax.swing.JToolBar$Separator" ) { + name: "separator1" + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "scrollButton" + "text": "scroll" + "font": new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scrollChanged", false ) ) + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "borderButton" + "text": "border" + "font": new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "borderChanged", false ) ) + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0,alignx right,growx 0" } ) add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { - name: "tabbedPane1" + name: "tabPlacementTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 1,width 300:300,height 100:100" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "tabLayoutLabel" + "text": "Tab layout" + "font": &SwingDerivedFont1 new com.jformdesigner.model.SwingDerivedFont( null, 0, 4, false ) auxiliary() { - "JavaCodeGenerator.variableLocal": false + "JavaCodeGenerator.variableLocal": true } - }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { - "gridX": 1 - "gridY": 3 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 2" + } ) + add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { + name: "tabLayoutToolBar" + "floatable": false + "border": new javax.swing.border.EmptyBorder( 0, 0, 0, 0 ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "scrollTabLayoutButton" + "text": "scroll" + "$buttonGroup": new FormReference( "buttonGroup2" ) + "font": &SwingDerivedFont2 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) + "selected": true + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabLayoutChanged", false ) ) + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "wrapTabLayoutButton" + "text": "wrap" + "$buttonGroup": new FormReference( "buttonGroup2" ) + "font": #SwingDerivedFont2 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabLayoutChanged", false ) ) + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 2,alignx right,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "scrollLayoutNoteLabel" + "text": "(use mouse wheel to scroll; arrow button shows hidden tabs)" + "enabled": false + "font": &SwingDerivedFont3 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 3" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "wrapLayoutNoteLabel" + "text": "(probably better to use scroll layout?)" + "enabled": false + "font": #SwingDerivedFont3 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 3" } ) add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { - name: "tabbedPane3" - "tabPlacement": 2 - auxiliary() { - "JavaCodeGenerator.variableLocal": false - } - }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { - "gridX": 3 - "gridY": 3 + name: "scrollLayoutTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 4" } ) add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { - name: "tabbedPane2" - "tabPlacement": 3 + name: "wrapLayoutTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 4,width 100:100,height pref*2px" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "closableTabsLabel" + "text": "Closable tabs" + "font": #SwingDerivedFont1 auxiliary() { - "JavaCodeGenerator.variableLocal": false + "JavaCodeGenerator.variableLocal": true } - }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { - "gridY": 5 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 5" + } ) + add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { + name: "closableTabsToolBar" + "floatable": false + "border": new javax.swing.border.EmptyBorder( 0, 0, 0, 0 ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "squareCloseButton" + "text": "square" + "font": &SwingDerivedFont4 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) + "$buttonGroup": new FormReference( "buttonGroup1" ) + "selected": true + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "closeButtonStyleChanged", false ) ) + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "circleCloseButton" + "text": "circle" + "font": #SwingDerivedFont4 + "$buttonGroup": new FormReference( "buttonGroup1" ) + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "closeButtonStyleChanged", false ) ) + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "redCrossCloseButton" + "text": "red cross" + "font": #SwingDerivedFont4 + "$buttonGroup": new FormReference( "buttonGroup1" ) + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "closeButtonStyleChanged", false ) ) + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 5,alignx right,growx 0" } ) add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { - name: "tabbedPane4" - "tabPlacement": 4 - auxiliary() { - "JavaCodeGenerator.variableLocal": false - } - }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { - "gridX": 3 - "gridY": 5 + name: "closableTabsTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 6" } ) - add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { - "$layoutConstraints": "insets 0,hidemode 3" - "$columnConstraints": "[][][][fill][]" - "$rowConstraints": "[center]" - } ) { - name: "panel14" - add( new FormComponent( "javax.swing.JCheckBox" ) { - name: "moreTabsCheckBox" - "text": "More tabs" - "mnemonic": 77 - auxiliary() { - "JavaCodeGenerator.variableLocal": false - } - addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "moreTabsChanged", false ) ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 0" + add( new FormComponent( "javax.swing.JLabel" ) { + name: "tabAreaComponentsLabel" + "text": "Custom tab area components" + "font": #SwingDerivedFont1 + auxiliary() { + "JavaCodeGenerator.variableLocal": true + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 7" + } ) + add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { + name: "tabAreaComponentsToolBar" + "floatable": false + "border": new javax.swing.border.EmptyBorder( 0, 0, 0, 0 ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "leadingComponentButton" + "text": "leading" + "font": &SwingDerivedFont5 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) + "selected": true + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "customComponentsChanged", false ) ) } ) - add( new FormComponent( "javax.swing.JCheckBox" ) { - name: "tabScrollCheckBox" - "text": "Use scroll layout" - "mnemonic": 83 - auxiliary() { - "JavaCodeGenerator.variableLocal": false - } - addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabScrollChanged", false ) ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 0,alignx left,growx 0" + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "trailingComponentButton" + "text": "trailing" + "font": #SwingDerivedFont5 + "selected": true + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "customComponentsChanged", false ) ) } ) - add( new FormComponent( "javax.swing.JCheckBox" ) { - name: "showTabSeparatorsCheckBox" - "text": "Show tab separators" - auxiliary() { - "JavaCodeGenerator.variableLocal": false - } - addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showTabSeparatorsChanged", false ) ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 0" - } ) - add( new FormComponent( "javax.swing.JCheckBox" ) { - name: "hideContentSeparatorCheckBox" - "text": "Hide content separator" - auxiliary() { - "JavaCodeGenerator.variableLocal": false - } - addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hideContentSeparatorChanged", false ) ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 0" - } ) - add( new FormComponent( "javax.swing.JCheckBox" ) { - name: "hasFullBorderCheckBox" - "text": "Show content border" - auxiliary() { - "JavaCodeGenerator.variableLocal": false - } - addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hasFullBorderChanged", false ) ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 0,alignx left,growx 0" - } ) - }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { - "gridY": 7 - "gridWidth": 3 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 7,alignx right,growx 0" + } ) + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "customComponentsTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 8" } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 0" } ) + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "insets 0,hidemode 3" + "$columnConstraints": "[grow,fill]" + "$rowConstraints": "[]0[][fill][center][center][center]para[center]0[][center][center][center][]" + } ) { + name: "panel2" + auxiliary() { + "JavaCodeGenerator.variableLocal": true + } + add( new FormComponent( "javax.swing.JLabel" ) { + name: "tabIconPlacementLabel" + "text": "Tab icon placement" + "font": new com.jformdesigner.model.SwingDerivedFont( null, 0, 4, false ) + auxiliary() { + "JavaCodeGenerator.variableLocal": true + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "tabIconPlacementNodeLabel" + "text": "(top/bottom/leading/trailing)" + "enabled": false + "font": new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) + auxiliary() { + "JavaCodeGenerator.variableLocal": true + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 1" + } ) + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "iconTopTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 2" + } ) + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "iconBottomTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 3" + } ) + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "iconLeadingTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 4" + } ) + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "iconTrailingTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 5" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "tabAreaAlignmentLabel" + "text": "Tab area alignment" + "font": &SwingDerivedFont6 new com.jformdesigner.model.SwingDerivedFont( null, 0, 4, false ) + auxiliary() { + "JavaCodeGenerator.variableLocal": true + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 6" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "tabAreaAlignmentNoteLabel" + "text": "(leading/center/trailing/fill)" + "enabled": false + "font": new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) + auxiliary() { + "JavaCodeGenerator.variableLocal": true + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 7" + } ) + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "alignLeadingTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 8" + } ) + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "alignCenterTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 9" + } ) + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "alignTrailingTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 10" + } ) + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "alignFillTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 11" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 0,growy" + } ) + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "insets 0,hidemode 3" + "$columnConstraints": "[grow,fill]" + "$rowConstraints": "[]0[][][][]para[][][]" + } ) { + name: "panel3" + auxiliary() { + "JavaCodeGenerator.variableLocal": true + } + add( new FormComponent( "javax.swing.JLabel" ) { + name: "tabWidthModeLabel" + "text": "Tab width mode" + "font": #SwingDerivedFont6 + auxiliary() { + "JavaCodeGenerator.variableLocal": true + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "tabWidthModeNoteLabel" + "text": "(preferred/equal/compact)" + "font": new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) + "enabled": false + auxiliary() { + "JavaCodeGenerator.variableLocal": true + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 1" + } ) + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "widthPreferredTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 2" + } ) + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "widthEqualTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 3" + } ) + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "widthCompactTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 4" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "minMaxTabWidthLabel" + "text": "Minimum/maximum tab width" + "font": new com.jformdesigner.model.SwingDerivedFont( null, 0, 4, false ) + auxiliary() { + "JavaCodeGenerator.variableLocal": true + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 5" + } ) + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "minimumTabWidthTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 6" + } ) + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "maximumTabWidthTabbedPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 7" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 0" + } ) + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "insets 0,hidemode 3" + "$columnConstraints": "[]" + "$rowConstraints": "[center]" + } ) { + name: "panel4" + auxiliary() { + "JavaCodeGenerator.variableLocal": true + } + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "showTabSeparatorsCheckBox" + "text": "Show tab separators" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showTabSeparatorsChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 1 3 1" + } ) }, new FormLayoutConstraints( null ) { "location": new java.awt.Point( 0, 0 ) - "size": new java.awt.Dimension( 700, 515 ) + "size": new java.awt.Dimension( 925, 825 ) + } ) + add( new FormNonVisual( "javax.swing.ButtonGroup" ) { + name: "tabPlacementButtonGroup" + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 10, 1240 ) + } ) + add( new FormNonVisual( "javax.swing.ButtonGroup" ) { + name: "buttonGroup1" + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 1292 ) + } ) + add( new FormNonVisual( "javax.swing.ButtonGroup" ) { + name: "buttonGroup2" + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 1344 ) } ) } } diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/RecentlyUsed.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/RecentlyUsed.svg new file mode 100644 index 00000000..10e24cb8 --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/RecentlyUsed.svg @@ -0,0 +1,3 @@ + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/favorite.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/favorite.svg new file mode 100644 index 00000000..592c1dcc --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/favorite.svg @@ -0,0 +1,3 @@ + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/search.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/search.svg new file mode 100644 index 00000000..1cf5bf50 --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/icons/search.svg @@ -0,0 +1,3 @@ + + +