From 51d7bc2c372c0c098649e724decc8c730aa2c3e4 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Thu, 2 Sep 2021 16:18:53 +0200 Subject: [PATCH 01/13] TextField, FormattedTextField, PasswordField and ComboBox: fixed alignment of placeholder text in right-to-left component orientation --- CHANGELOG.md | 2 ++ .../main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4c7d432..fc7efe32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ FlatLaf Change Log since FlatLaf 1.3) - OptionPane: Fixed `OptionPane.sameSizeButtons`, which did not work as expected when setting to `false`. +- TextField, FormattedTextField, PasswordField and ComboBox: Fixed alignment of + placeholder text in right-to-left component orientation. ## 1.5 diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java index 923458a0..5a02d059 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java @@ -237,12 +237,13 @@ public class FlatTextFieldUI // compute placeholder location Rectangle r = getVisibleEditorRect(); FontMetrics fm = c.getFontMetrics( c.getFont() ); + String clippedPlaceholder = JavaCompatibility.getClippedString( c, fm, (String) placeholder, r.width ); + int x = r.x + (c.getComponentOrientation().isLeftToRight() ? 0 : r.width - fm.stringWidth( clippedPlaceholder )); int y = r.y + fm.getAscent() + ((r.height - fm.getHeight()) / 2); // paint placeholder g.setColor( placeholderForeground ); - String clippedPlaceholder = JavaCompatibility.getClippedString( c, fm, (String) placeholder, r.width ); - FlatUIUtils.drawString( c, g, clippedPlaceholder, r.x, y ); + FlatUIUtils.drawString( c, g, clippedPlaceholder, x, y ); } @Override From b25fcc3381b338b5fb004c6c43b07a47e5242ec7 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Fri, 3 Sep 2021 11:20:46 +0200 Subject: [PATCH 02/13] OptionPane: fixed rendering of longer HTML text if it is passed as `StringBuilder`, `StringBuffer`, or any other object that returns HTML text in method `toString()` (similar to issue #12) --- CHANGELOG.md | 3 +++ .../com/formdev/flatlaf/ui/FlatOptionPaneUI.java | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc7efe32..ac966eb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ FlatLaf Change Log since FlatLaf 1.3) - OptionPane: Fixed `OptionPane.sameSizeButtons`, which did not work as expected when setting to `false`. +- OptionPane: Fixed rendering of longer HTML text if it is passed as + `StringBuilder`, `StringBuffer`, or any other object that returns HTML text in + method `toString()`. (similar to issue #12) - TextField, FormattedTextField, PasswordField and ComboBox: Fixed alignment of placeholder text in right-to-left component orientation. diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatOptionPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatOptionPaneUI.java index 2bb2c8f9..d0413691 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatOptionPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatOptionPaneUI.java @@ -24,6 +24,7 @@ import java.awt.GridBagConstraints; import java.awt.Insets; import javax.swing.Box; import javax.swing.BoxLayout; +import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; @@ -162,8 +163,15 @@ public class FlatOptionPaneUI cons.insets.bottom = UIScale.scale( messagePadding ); // disable line wrapping for HTML - if( msg instanceof String && BasicHTML.isHTMLString( (String) msg ) ) - maxll = Integer.MAX_VALUE; + if( msg != null && + !(msg instanceof Component) && + !(msg instanceof Object[]) && + !(msg instanceof Icon) ) + { + msg = msg.toString(); + if( BasicHTML.isHTMLString( (String) msg ) ) + maxll = Integer.MAX_VALUE; + } // fix right-to-left alignment if super.addMessageComponents() breaks longer lines // into multiple labels and puts them into a box that aligns them to the left From 78a9cc1d0c150b29f1950bfd9e6d7ebac96bcf90 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Fri, 3 Sep 2021 17:32:59 +0200 Subject: [PATCH 03/13] Theme Editor: fixed: editor was not focused after startup or when switching directory --- .../com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java index c3b53a64..03c35552 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeFileEditor.java @@ -280,7 +280,9 @@ class FlatThemeFileEditor for( File file : getPropertiesFiles( dir ) ) openFile( file, file.getName().equals( recentFile ) ); - activateEditor(); + SwingUtilities.invokeLater( () -> { + activateEditor(); + } ); saveState(); enableDisableActions(); From 253df9325dd125b6d22cf9079fbb974af79e89c3 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sat, 4 Sep 2021 13:19:12 +0200 Subject: [PATCH 04/13] Extras: FlatAnimatedLafChange: made animated Laf change transition smoother --- .../com/formdev/flatlaf/extras/FlatAnimatedLafChange.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatAnimatedLafChange.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatAnimatedLafChange.java index f66cefe1..b46d26f4 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatAnimatedLafChange.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatAnimatedLafChange.java @@ -19,6 +19,7 @@ package com.formdev.flatlaf.extras; import java.awt.AlphaComposite; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Toolkit; import java.awt.Window; import java.awt.image.VolatileImage; import java.util.Map; @@ -51,9 +52,9 @@ public class FlatAnimatedLafChange public static int duration = 160; /** - * The resolution of the animation in milliseconds. Default is 40 ms. + * The resolution of the animation in milliseconds. Default is 30 ms. */ - public static int resolution = 40; + public static int resolution = 30; private static Animator animator; private static final Map oldUIsnapshots = new WeakHashMap<>(); @@ -158,6 +159,8 @@ public class FlatAnimatedLafChange if( e.getKey().isShowing() ) e.getValue().repaint(); } + + Toolkit.getDefaultToolkit().sync(); }, () -> { hideSnapshot(); animator = null; From b98b904023ffcda8ae5e0aaa57f8ff498cb54e36 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sat, 4 Sep 2021 13:24:19 +0200 Subject: [PATCH 05/13] added missing UI defaults to javadoc --- .../src/main/java/com/formdev/flatlaf/ui/FlatBorder.java | 1 + .../java/com/formdev/flatlaf/ui/FlatPopupMenuSeparatorUI.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatBorder.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatBorder.java index 9ffb05c0..276a591a 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatBorder.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatBorder.java @@ -45,6 +45,7 @@ import com.formdev.flatlaf.util.DerivedColor; * * @uiDefault Component.focusWidth int * @uiDefault Component.innerFocusWidth int or float + * @uiDefault Component.innerOutlineWidth int or float * @uiDefault Component.focusColor Color * @uiDefault Component.borderColor Color * @uiDefault Component.disabledBorderColor Color diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupMenuSeparatorUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupMenuSeparatorUI.java index a51fcd54..f6181fe4 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupMenuSeparatorUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupMenuSeparatorUI.java @@ -24,8 +24,8 @@ import javax.swing.plaf.ComponentUI; * * * - * @uiDefault PopupMenuSeparator.background Color unused - * @uiDefault PopupMenuSeparator.foreground Color + * @uiDefault Separator.background Color unused + * @uiDefault Separator.foreground Color * * * From c7054537e7beff08392cfd2f7e00e31e4d4a039c Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sat, 4 Sep 2021 13:28:02 +0200 Subject: [PATCH 06/13] Testing: FlatSingleComponentTest: support changing component orientation using `Alt+R` --- .../flatlaf/testing/FlatSingleComponentTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSingleComponentTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSingleComponentTest.java index 33981036..2465c478 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSingleComponentTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatSingleComponentTest.java @@ -16,6 +16,7 @@ package com.formdev.flatlaf.testing; +import java.awt.ComponentOrientation; import java.awt.Container; import java.awt.Dimension; import java.awt.EventQueue; @@ -132,6 +133,16 @@ public class FlatSingleComponentTest registerScaleFactor( "alt F11", "6" ); registerScaleFactor( "alt F12", null ); + // register Alt+R key to toggle component orientation + ((JComponent)getContentPane()).registerKeyboardAction( + e -> { + applyComponentOrientation( getComponentOrientation().isLeftToRight() + ? ComponentOrientation.RIGHT_TO_LEFT + : ComponentOrientation.LEFT_TO_RIGHT ); + }, + KeyStroke.getKeyStroke( "alt R" ), + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ); + // register ESC key to close frame ((JComponent)getContentPane()).registerKeyboardAction( e -> { From d508f339c1ec7424be5ea369089990fadea88698 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sat, 4 Sep 2021 18:20:21 +0200 Subject: [PATCH 07/13] TableHeader: do not show resize cursor for last column if resizing last column is not possible because auto resize mode of table is not off (issue #332) --- CHANGELOG.md | 2 + .../formdev/flatlaf/ui/FlatTableHeaderUI.java | 59 +++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac966eb5..5c7e1ae7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ FlatLaf Change Log - OptionPane: Fixed rendering of longer HTML text if it is passed as `StringBuilder`, `StringBuffer`, or any other object that returns HTML text in method `toString()`. (similar to issue #12) +- TableHeader: Do not show resize cursor for last column if resizing last column + is not possible because auto resize mode of table is not off. (issue #332) - TextField, FormattedTextField, PasswordField and ComboBox: Fixed alignment of placeholder text in right-to-left component orientation. diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java index 2ef512de..82d861ad 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java @@ -18,10 +18,13 @@ package com.formdev.flatlaf.ui; import java.awt.Color; import java.awt.Component; +import java.awt.Cursor; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; import java.awt.geom.Rectangle2D; import java.util.Objects; import javax.swing.Icon; @@ -31,6 +34,7 @@ import javax.swing.JTable; import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.border.Border; +import javax.swing.event.MouseInputListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicTableHeaderUI; @@ -94,6 +98,11 @@ public class FlatTableHeaderUI bottomSeparatorColor = null; } + @Override + protected MouseInputListener createMouseInputListener() { + return new FlatMouseInputHandler(); + } + // overridden and made public to allow usage in custom renderers @Override public int getRolloverColumn() { @@ -252,4 +261,54 @@ public class FlatTableHeaderUI return (origBorder != null) ? origBorder.isBorderOpaque() : false; } } + + //---- class FlatMouseInputHandler ---------------------------------------- + + /** + * @since 1.6 + */ + protected class FlatMouseInputHandler + extends MouseInputHandler + { + Cursor oldCursor; + + @Override + public void mouseMoved( MouseEvent e ) { + // restore old cursor, which is necessary because super.mouseMoved() swaps cursors + if( oldCursor != null ) { + header.setCursor( oldCursor ); + oldCursor = null; + } + + super.mouseMoved( e ); + + // if resizing last column is not possible, then Swing still shows a resize cursor, + // which can be confusing for the user --> change cursor to standard cursor + JTable table; + int column; + if( header.isEnabled() && + (table = header.getTable()) != null && + table.getAutoResizeMode() != JTable.AUTO_RESIZE_OFF && + header.getCursor() == Cursor.getPredefinedCursor( Cursor.E_RESIZE_CURSOR ) && + (column = header.columnAtPoint( e.getPoint() )) >= 0 && + column == header.getColumnModel().getColumnCount() - 1 ) + { + // mouse is in last column + Rectangle r = header.getHeaderRect( column ); + r.grow( -3, 0 ); + if( !r.contains( e.getX(), e.getY() ) ) { + // mouse is in left or right resize area of last column + boolean isResizeLastColumn = (e.getX() >= r.x + (r.width / 2)); + if( !header.getComponentOrientation().isLeftToRight() ) + isResizeLastColumn = !isResizeLastColumn; + + if( isResizeLastColumn ) { + // resize is not possible --> change cursor to standard cursor + oldCursor = header.getCursor(); + header.setCursor( Cursor.getDefaultCursor() ); + } + } + } + } + } } From 4795fe56876ec536be4aa7f35d20789d5956e3f4 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 5 Sep 2021 10:55:51 +0200 Subject: [PATCH 08/13] Theme Editor: - added preview of buttons, checkboxes, radiobuttons, etc in various states (hover, pressed, focused, selected, disabled) (copied from `FlatComponentStateTest`) - moved components preview panel from FlatThemePreview.jfd` to FlatThemePreviewAll.jfd` - added tabs at top of preview area --- .../testing/FlatComponentStateTest.java | 2 +- .../themeeditor/FlatThemeEditorPane.java | 12 +- .../flatlaf/themeeditor/FlatThemePreview.java | 1040 ++--------------- .../flatlaf/themeeditor/FlatThemePreview.jfd | 643 +--------- .../themeeditor/FlatThemePreviewAll.java | 891 ++++++++++++++ .../themeeditor/FlatThemePreviewAll.jfd | 624 ++++++++++ .../themeeditor/FlatThemePreviewButtons.java | 705 +++++++++++ .../themeeditor/FlatThemePreviewButtons.jfd | 507 ++++++++ .../themeeditor/FlatThemePreviewSwitches.java | 558 +++++++++ .../themeeditor/FlatThemePreviewSwitches.jfd | 379 ++++++ 10 files changed, 3801 insertions(+), 1560 deletions(-) create mode 100644 flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java create mode 100644 flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.jfd create mode 100644 flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.java create mode 100644 flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.jfd create mode 100644 flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.java create mode 100644 flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.jfd diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentStateTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentStateTest.java index 49a0e4d3..b457a26f 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentStateTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentStateTest.java @@ -1076,7 +1076,7 @@ public class FlatComponentStateTest } } - //---- class TestStateCheckBox -------------------------------------------- + //---- class TestStateRadioButton ----------------------------------------- private static class TestStateRadioButton extends JRadioButton diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java index f0d37ff6..a4b3d4da 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemeEditorPane.java @@ -31,7 +31,6 @@ import javax.swing.JFrame; import javax.swing.JLayer; import javax.swing.JOptionPane; import javax.swing.JPanel; -import javax.swing.JScrollPane; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -68,7 +67,6 @@ class FlatThemeEditorPane private final FlatSyntaxTextArea textArea; private final ErrorStrip errorStrip; private FlatFindReplaceBar findReplaceBar; - private JScrollPane previewScrollPane; private FlatThemePreview preview; private File file; @@ -273,18 +271,12 @@ class FlatThemeEditorPane return; preview = new FlatThemePreview( textArea ); - previewScrollPane = new JScrollPane( preview ); - previewScrollPane.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - previewScrollPane.setBorder( BorderFactory.createEmptyBorder() ); - previewScrollPane.getVerticalScrollBar().setUnitIncrement( 20 ); - previewScrollPane.getHorizontalScrollBar().setUnitIncrement( 20 ); - add( previewScrollPane, BorderLayout.LINE_END ); + add( preview, BorderLayout.LINE_END ); } else { if( preview == null ) return; - remove( previewScrollPane ); - previewScrollPane = null; + remove( preview ); preview = null; } diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.java index eb3d857d..102b798e 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.java @@ -18,25 +18,16 @@ package com.formdev.flatlaf.themeeditor; import java.awt.*; -import java.awt.event.ActionEvent; import java.awt.event.HierarchyEvent; -import java.beans.PropertyVetoException; import java.util.Map; import java.util.WeakHashMap; -import java.util.function.Function; import javax.swing.*; import javax.swing.UIDefaults.ActiveValue; import javax.swing.UIDefaults.LazyValue; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableRowSorter; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeModel; import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.extras.components.*; -import com.formdev.flatlaf.ui.FlatTabbedPaneUI; -import net.miginfocom.swing.*; /** * @author Karl Tauber @@ -56,36 +47,9 @@ class FlatThemePreview initComponents(); - tabbedPane1.uiDefaultsGetter = this::getUIDefaultProperty; - tabbedPane1.setTabLayoutPolicy( JTabbedPane.SCROLL_TAB_LAYOUT ); - tabbedPane1.addTab( "Tab 1", null ); - tabbedPane1.addTab( "Tab 2", null ); - tabbedPane1.addTab( "Tab 3", null ); - tabbedPane1.addTab( "Tab 4", null ); - tabbedPane1.addTab( "Tab 5", null ); - tabbedPane1.addTab( "Tab 6", null ); - tabbedPane1.addTab( "Tab 7", null ); - tabbedPane1.addTab( "Tab 8", null ); - - list1.setSelectedIndex( 1 ); - tree1.setSelectionRow( 1 ); - table1.setRowSelectionInterval( 1, 1 ); - table1.setRowSorter( new TableRowSorter<>( table1.getModel() ) ); - table1.getRowSorter().toggleSortOrder( 0 ); - table1.uiDefaultsGetter = this::getUIDefaultProperty; - - EventQueue.invokeLater( () -> { - int width = desktopPane1.getWidth(); - int height = desktopPane1.getHeight() / 2; - internalFrame1.setBounds( 0, 0, width, height ); - internalFrame2.setBounds( 0, height, width, height ); - - try { - internalFrame1.setSelected( true ); - } catch( PropertyVetoException ex ) { - // ignore - } - } ); + tabbedPane.addTab( "All", createPreviewTab( new FlatThemePreviewAll( this ) ) ); + tabbedPane.addTab( "Buttons", createPreviewTab( new FlatThemePreviewButtons() ) ); + tabbedPane.addTab( "Switches", createPreviewTab( new FlatThemePreviewSwitches() ) ); // timer used for delayed preview updates timer = new Timer( 300, e -> update() ); @@ -101,6 +65,15 @@ class FlatThemePreview } ); } + private JScrollPane createPreviewTab( JComponent c ) { + JScrollPane scrollPane = new JScrollPane( new PreviewPanel( c ) ); + scrollPane.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); + scrollPane.setBorder( BorderFactory.createEmptyBorder() ); + scrollPane.getVerticalScrollBar().setUnitIncrement( 20 ); + scrollPane.getHorizontalScrollBar().setUnitIncrement( 20 ); + return scrollPane; + } + @Override public void insertUpdate( DocumentEvent e ) { timer.restart(); @@ -128,13 +101,18 @@ class FlatThemePreview private void updateComponentTreeUI() { try { - SwingUtilities.updateComponentTreeUI( this ); + Component selComp = tabbedPane.getSelectedComponent(); + if( selComp != null ) { + if( selComp instanceof JScrollPane ) + selComp = ((JScrollPane)selComp).getViewport().getView(); + SwingUtilities.updateComponentTreeUI( selComp ); + } } catch( Exception ex ) { ex.printStackTrace(); } } - private void runWithUIDefaultsGetter( Runnable runnable ) { + void runWithUIDefaultsGetter( Runnable runnable ) { try { runWithUIDefaultsGetterLevel++; if( runWithUIDefaultsGetterLevel == 1 ) @@ -146,7 +124,7 @@ class FlatThemePreview } } - private Object getUIDefaultProperty( Object key ) { + Object getUIDefaultProperty( Object key ) { if( !(key instanceof String) ) return null; @@ -178,919 +156,133 @@ class FlatThemePreview return value; } - @SuppressWarnings( "deprecation" ) - @Override - public void layout() { - try { - runWithUIDefaultsGetter( () -> { - super.layout(); - } ); - } catch( Exception ex ) { - ex.printStackTrace(); - } - } - - @Override - protected void validateTree() { - try { - runWithUIDefaultsGetter( () -> { - super.validateTree(); - } ); - } catch( Exception ex ) { - ex.printStackTrace(); - } - } - - @Override - public Dimension getPreferredSize() { - try { - return super.getPreferredSize(); - } catch( Exception ex ) { - ex.printStackTrace(); - return new Dimension( 100, 100 ); - } - } - - @Override - public Dimension getMinimumSize() { - try { - return super.getMinimumSize(); - } catch( Exception ex ) { - ex.printStackTrace(); - return new Dimension( 100, 100 ); - } - } - - @Override - public Dimension getMaximumSize() { - try { - return super.getMaximumSize(); - } catch( Exception ex ) { - ex.printStackTrace(); - return new Dimension( Short.MAX_VALUE, Short.MAX_VALUE ); - } - } - - @Override - public void paint( Graphics g ) { - try { - runWithUIDefaultsGetter( () -> { - super.paint( g ); - } ); - } catch( Exception ex ) { - ex.printStackTrace(); - } - } - - @Override - protected void paintComponent( Graphics g ) { - try { - runWithUIDefaultsGetter( () -> { - super.paintComponent( g ); - } ); - } catch( Exception ex ) { - ex.printStackTrace(); - } - } - - @Override - protected void paintChildren( Graphics g ) { - try { - runWithUIDefaultsGetter( () -> { - super.paintChildren( g ); - } ); - } catch( Exception ex ) { - ex.printStackTrace(); - } - } - - private void enabledChanged() { - runWithUIDefaultsGetter( () -> { - enableDisable( this, enabledCheckBox.isSelected() ); - } ); - } - - private void enableDisable( Component comp, boolean enabled ) { - if( comp != previewLabel && comp != enabledCheckBox && comp != menu2 ) - comp.setEnabled( enabled ); - - if( !(comp instanceof Container) || comp instanceof JInternalFrame ) - return; - - for( Component c : ((Container)comp).getComponents() ) { - if( c instanceof JScrollPane ) - c = ((JScrollPane)c).getViewport().getView(); - - // make sure that background is updated correctly in BasicTextUI.updateBackground() - if( c instanceof JTextPane ) - c.setBackground( UIManager.getColor( "TextPane.background" ) ); - else if( c instanceof JEditorPane ) - c.setBackground( UIManager.getColor( "EditorPane.background" ) ); - - enableDisable( c, enabled ); - } - - if( comp instanceof JMenu ) { - JMenu menu = (JMenu) comp; - int count = menu.getMenuComponentCount(); - for( int i = 0; i < count; i++ ) - enableDisable( menu.getMenuComponent( i ), enabled ); - } - } - - private void changeProgress() { - int value = slider3.getValue(); - progressBar1.setValue( value ); - progressBar2.setValue( value ); - } - - private Object toolbarCons; - - @Override - protected void addImpl( Component comp, Object constraints, int index ) { - // if floating toolbar window is closed, then place toolbar at original location - if( comp == toolBar1 ) { - if( toolbarCons == null ) - toolbarCons = constraints; - else if( comp.getParent() == null && toolbarCons != null ) - constraints = toolbarCons; - } - - super.addImpl( comp, constraints, index ); - } - private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents + tabbedPane = new FlatTabbedPane(); previewSeparator = new JSeparator(); previewLabel = new JLabel(); - enabledCheckBox = new JCheckBox(); - separator2 = new JSeparator(); - labelLabel = new JLabel(); - label1 = new JLabel(); - flatButton1 = new FlatButton(); - buttonLabel = new JLabel(); - button1 = new JButton(); - testDefaultButton1 = new FlatThemePreview.PreviewDefaultButton(); - helpButton = new FlatButton(); - hSpacer2 = new JPanel(null); - toggleButtonLabel = new JLabel(); - toggleButton1 = new JToggleButton(); - toggleButton3 = new JToggleButton(); - hSpacer1 = new JPanel(null); - checkBoxLabel = new JLabel(); - checkBox1 = new JCheckBox(); - checkBox3 = new JCheckBox(); - hSpacer3 = new JPanel(null); - radioButtonLabel = new JLabel(); - radioButton1 = new JRadioButton(); - radioButton3 = new JRadioButton(); - hSpacer4 = new JPanel(null); - comboBoxLabel = new JLabel(); - comboBox1 = new FlatComboBox<>(); - comboBox3 = new JComboBox<>(); - spinnerLabel = new JLabel(); - spinner1 = new JSpinner(); - textFieldLabel = new JLabel(); - textField1 = new FlatTextField(); - formattedTextField1 = new FlatFormattedTextField(); - passwordField1 = new FlatPasswordField(); - textAreaLabel = new JLabel(); - scrollPane1 = new JScrollPane(); - textArea1 = new JTextArea(); - scrollPane5 = new JScrollPane(); - editorPane1 = new JEditorPane(); - scrollPane9 = new JScrollPane(); - textPane1 = new JTextPane(); - menuBarLabel = new JLabel(); - menuBar1 = new JMenuBar(); - menu2 = new JMenu(); - menuItem3 = new JMenuItem(); - menuItem4 = new JMenuItem(); - checkBoxMenuItem2 = new JCheckBoxMenuItem(); - checkBoxMenuItem3 = new JCheckBoxMenuItem(); - radioButtonMenuItem4 = new JRadioButtonMenuItem(); - radioButtonMenuItem5 = new JRadioButtonMenuItem(); - menu4 = new JMenu(); - menuItem6 = new JMenuItem(); - menu5 = new JMenu(); - menuItem7 = new JMenuItem(); - menu3 = new JMenu(); - menuItem5 = new JMenuItem(); - menuItem8 = new JMenuItem(); - menuItem9 = new JMenuItem(); - scrollBarLabel = new JLabel(); - scrollBar1 = new JScrollBar(); - scrollBar5 = new FlatScrollBar(); - separatorLabel = new JLabel(); - separator1 = new JSeparator(); - sliderLabel = new JLabel(); - slider1 = new JSlider(); - slider3 = new JSlider(); - progressBarLabel = new JLabel(); - progressBar1 = new FlatProgressBar(); - progressBar2 = new FlatProgressBar(); - toolTipLabel = new JLabel(); - toolTip1 = new JToolTip(); - toolBarLabel = new JLabel(); - toolBar1 = new JToolBar(); - button4 = new JButton(); - button6 = new JButton(); - button7 = new JToggleButton(); - button8 = new JToggleButton(); - tabbedPaneLabel = new JLabel(); - tabbedPane1 = new FlatThemePreview.PreviewTabbedPane(); - listTreeLabel = new JLabel(); - splitPane1 = new JSplitPane(); - scrollPane2 = new JScrollPane(); - list1 = new JList<>(); - scrollPane3 = new JScrollPane(); - tree1 = new JTree(); - tableLabel = new JLabel(); - scrollPane4 = new JScrollPane(); - table1 = new FlatThemePreview.PreviewTable(); - internalFrameLabel = new JLabel(); - desktopPane1 = new JDesktopPane(); - internalFrame1 = new JInternalFrame(); - internalFrame2 = new JInternalFrame(); //======== this ======== - setLayout(new MigLayout( - "insets dialog,hidemode 3", - // columns - "[fill]" + - "[130,fill]", - // rows - "[]0" + - "[]unrel" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[]" + - "[100,fill]" + - "[grow]")); + setLayout(new BorderLayout()); + + //======== tabbedPane ======== + { + tabbedPane.setLeadingComponent(previewLabel); + tabbedPane.setTabAreaAlignment(FlatTabbedPane.TabAreaAlignment.trailing); + tabbedPane.addChangeListener(e -> update()); + } + add(tabbedPane, BorderLayout.CENTER); //---- previewSeparator ---- previewSeparator.setOrientation(SwingConstants.VERTICAL); - add(previewSeparator, "west"); + add(previewSeparator, BorderLayout.LINE_START); //---- previewLabel ---- - previewLabel.setText("Preview"); + previewLabel.setText(" Preview "); previewLabel.setFont(previewLabel.getFont().deriveFont(previewLabel.getFont().getSize() + 6f)); - add(previewLabel, "cell 0 0 2 1,alignx left,growx 0"); - - //---- enabledCheckBox ---- - enabledCheckBox.setText("Enabled"); - enabledCheckBox.setSelected(true); - enabledCheckBox.addActionListener(e -> enabledChanged()); - add(enabledCheckBox, "cell 0 0 2 1,align right top,grow 0 0"); - add(separator2, "cell 0 1 2 1"); - - //---- labelLabel ---- - labelLabel.setText("JLabel:"); - add(labelLabel, "cell 0 2"); - - //---- label1 ---- - label1.setText("Some Text"); - add(label1, "cell 1 2"); - - //---- flatButton1 ---- - flatButton1.setText("Help"); - flatButton1.setButtonType(FlatButton.ButtonType.help); - flatButton1.setVisible(false); - add(flatButton1, "cell 1 1,alignx right,growx 0"); - - //---- buttonLabel ---- - buttonLabel.setText("JButton:"); - add(buttonLabel, "cell 0 3"); - - //---- button1 ---- - button1.setText("OK"); - add(button1, "cell 1 3,alignx left,growx 0"); - - //---- testDefaultButton1 ---- - testDefaultButton1.setText("Default"); - add(testDefaultButton1, "cell 1 3"); - - //---- helpButton ---- - helpButton.setButtonType(FlatButton.ButtonType.help); - add(helpButton, "cell 1 3"); - add(hSpacer2, "cell 1 3"); - - //---- toggleButtonLabel ---- - toggleButtonLabel.setText("JToggleButton:"); - add(toggleButtonLabel, "cell 0 4"); - - //---- toggleButton1 ---- - toggleButton1.setText("Unselected"); - add(toggleButton1, "cell 1 4,alignx left,growx 0"); - - //---- toggleButton3 ---- - toggleButton3.setText("Selected"); - toggleButton3.setSelected(true); - add(toggleButton3, "cell 1 4"); - add(hSpacer1, "cell 1 4"); - - //---- checkBoxLabel ---- - checkBoxLabel.setText("JCheckBox"); - add(checkBoxLabel, "cell 0 5"); - - //---- checkBox1 ---- - checkBox1.setText("Unselected"); - add(checkBox1, "cell 1 5,alignx left,growx 0"); - - //---- checkBox3 ---- - checkBox3.setText("Selected"); - checkBox3.setSelected(true); - add(checkBox3, "cell 1 5,alignx left,growx 0"); - add(hSpacer3, "cell 1 5"); - - //---- radioButtonLabel ---- - radioButtonLabel.setText("JRadioButton:"); - add(radioButtonLabel, "cell 0 6"); - - //---- radioButton1 ---- - radioButton1.setText("Unselected"); - add(radioButton1, "cell 1 6,alignx left,growx 0"); - - //---- radioButton3 ---- - radioButton3.setText("Selected"); - radioButton3.setSelected(true); - add(radioButton3, "cell 1 6,alignx left,growx 0"); - add(hSpacer4, "cell 1 6"); - - //---- comboBoxLabel ---- - comboBoxLabel.setText("JComboBox:"); - add(comboBoxLabel, "cell 0 7"); - - //---- comboBox1 ---- - comboBox1.setEditable(true); - comboBox1.setModel(new DefaultComboBoxModel<>(new String[] { - "Editable", - "a", - "bb", - "ccc", - "dd", - "e", - "ff", - "ggg", - "hh", - "i", - "jj", - "kkk" - })); - comboBox1.setMaximumRowCount(6); - comboBox1.setPlaceholderText("placeholder text"); - add(comboBox1, "cell 1 7,width 50"); - - //---- comboBox3 ---- - comboBox3.setModel(new DefaultComboBoxModel<>(new String[] { - "Not edit", - "a", - "bb", - "ccc", - "dd", - "e", - "ff", - "ggg", - "hh", - "i", - "jj", - "kkk" - })); - comboBox3.setMaximumRowCount(6); - add(comboBox3, "cell 1 7,width 50"); - - //---- spinnerLabel ---- - spinnerLabel.setText("JSpinner:"); - add(spinnerLabel, "cell 0 8"); - add(spinner1, "cell 1 8"); - - //---- textFieldLabel ---- - textFieldLabel.setText("JTextField:
JFormattedTextF.:
JPasswordField:"); - add(textFieldLabel, "cell 0 9 1 2"); - - //---- textField1 ---- - textField1.setText("Some Text"); - textField1.setPlaceholderText("placeholder text"); - add(textField1, "cell 1 9"); - - //---- formattedTextField1 ---- - formattedTextField1.setText("Some Text"); - formattedTextField1.setPlaceholderText("placeholder text"); - add(formattedTextField1, "cell 1 10,width 50"); - - //---- passwordField1 ---- - passwordField1.setText("Some Text"); - passwordField1.setPlaceholderText("placeholder text"); - add(passwordField1, "cell 1 10,width 50"); - - //---- textAreaLabel ---- - textAreaLabel.setText("JTextArea:

JEditorPane:
JTextPane:"); - add(textAreaLabel, "cell 0 11 1 2"); - - //======== scrollPane1 ======== - { - scrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); - scrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - - //---- textArea1 ---- - textArea1.setText("Some Text"); - textArea1.setRows(2); - scrollPane1.setViewportView(textArea1); - } - add(scrollPane1, "cell 1 11"); - - //======== scrollPane5 ======== - { - scrollPane5.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); - scrollPane5.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - - //---- editorPane1 ---- - editorPane1.setText("Some Text"); - scrollPane5.setViewportView(editorPane1); - } - add(scrollPane5, "cell 1 12,width 50"); - - //======== scrollPane9 ======== - { - scrollPane9.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); - scrollPane9.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - - //---- textPane1 ---- - textPane1.setText("Some Text"); - scrollPane9.setViewportView(textPane1); - } - add(scrollPane9, "cell 1 12,width 50"); - - //---- menuBarLabel ---- - menuBarLabel.setText("JMenuBar:"); - add(menuBarLabel, "cell 0 13"); - - //======== menuBar1 ======== - { - - //======== menu2 ======== - { - menu2.setText("JMenu"); - - //---- menuItem3 ---- - menuItem3.setText("JMenuItem"); - menu2.add(menuItem3); - - //---- menuItem4 ---- - menuItem4.setText("JMenuItem"); - menu2.add(menuItem4); - menu2.addSeparator(); - - //---- checkBoxMenuItem2 ---- - checkBoxMenuItem2.setText("JCheckBoxMenuItem"); - checkBoxMenuItem2.setSelected(true); - menu2.add(checkBoxMenuItem2); - - //---- checkBoxMenuItem3 ---- - checkBoxMenuItem3.setText("JCheckBoxMenuItem"); - menu2.add(checkBoxMenuItem3); - menu2.addSeparator(); - - //---- radioButtonMenuItem4 ---- - radioButtonMenuItem4.setText("JRadioButtonMenuItem"); - radioButtonMenuItem4.setSelected(true); - menu2.add(radioButtonMenuItem4); - - //---- radioButtonMenuItem5 ---- - radioButtonMenuItem5.setText("JRadioButtonMenuItem"); - menu2.add(radioButtonMenuItem5); - menu2.addSeparator(); - - //======== menu4 ======== - { - menu4.setText("JMenu"); - - //---- menuItem6 ---- - menuItem6.setText("JMenuItem"); - menu4.add(menuItem6); - } - menu2.add(menu4); - - //======== menu5 ======== - { - menu5.setText("JMenu"); - - //---- menuItem7 ---- - menuItem7.setText("JMenuItem"); - menu5.add(menuItem7); - } - menu2.add(menu5); - } - menuBar1.add(menu2); - - //======== menu3 ======== - { - menu3.setText("JMenu"); - - //---- menuItem5 ---- - menuItem5.setText("JMenuItem"); - menu3.add(menuItem5); - - //---- menuItem8 ---- - menuItem8.setText("JMenuItem"); - menu3.add(menuItem8); - - //---- menuItem9 ---- - menuItem9.setText("JMenuItem"); - menu3.add(menuItem9); - } - menuBar1.add(menu3); - } - add(menuBar1, "cell 1 13"); - - //---- scrollBarLabel ---- - scrollBarLabel.setText("JScrollBar:"); - add(scrollBarLabel, "cell 0 14"); - - //---- scrollBar1 ---- - scrollBar1.setOrientation(Adjustable.HORIZONTAL); - add(scrollBar1, "cell 1 14"); - - //---- scrollBar5 ---- - scrollBar5.setOrientation(Adjustable.HORIZONTAL); - scrollBar5.setShowButtons(true); - add(scrollBar5, "cell 1 15"); - - //---- separatorLabel ---- - separatorLabel.setText("JSeparator:"); - add(separatorLabel, "cell 0 16"); - add(separator1, "cell 1 16"); - - //---- sliderLabel ---- - sliderLabel.setText("JSlider:"); - add(sliderLabel, "cell 0 17"); - - //---- slider1 ---- - slider1.setValue(30); - add(slider1, "cell 1 17"); - - //---- slider3 ---- - slider3.setMinorTickSpacing(10); - slider3.setPaintTicks(true); - slider3.setMajorTickSpacing(50); - slider3.setPaintLabels(true); - slider3.setValue(30); - slider3.addChangeListener(e -> changeProgress()); - add(slider3, "cell 1 18"); - - //---- progressBarLabel ---- - progressBarLabel.setText("JProgressBar:"); - add(progressBarLabel, "cell 0 19"); - - //---- progressBar1 ---- - progressBar1.setValue(60); - add(progressBar1, "cell 1 19"); - - //---- progressBar2 ---- - progressBar2.setValue(50); - progressBar2.setStringPainted(true); - add(progressBar2, "cell 1 20"); - - //---- toolTipLabel ---- - toolTipLabel.setText("JToolTip:"); - add(toolTipLabel, "cell 0 21"); - - //---- toolTip1 ---- - toolTip1.setTipText("Some text in tool tip."); - add(toolTip1, "cell 1 21,alignx left,growx 0"); - - //---- toolBarLabel ---- - toolBarLabel.setText("JToolBar:"); - add(toolBarLabel, "cell 0 22"); - - //======== toolBar1 ======== - { - - //---- button4 ---- - button4.setIcon(UIManager.getIcon("Tree.closedIcon")); - toolBar1.add(button4); - - //---- button6 ---- - button6.setIcon(UIManager.getIcon("Tree.openIcon")); - toolBar1.add(button6); - toolBar1.addSeparator(); - - //---- button7 ---- - button7.setIcon(UIManager.getIcon("Tree.leafIcon")); - toolBar1.add(button7); - - //---- button8 ---- - button8.setIcon(UIManager.getIcon("Tree.leafIcon")); - button8.setSelected(true); - toolBar1.add(button8); - } - add(toolBar1, "cell 1 22"); - - //---- tabbedPaneLabel ---- - tabbedPaneLabel.setText("JTabbedPane:"); - add(tabbedPaneLabel, "cell 0 23"); - add(tabbedPane1, "cell 1 23"); - - //---- listTreeLabel ---- - listTreeLabel.setText("JList / JTree:
JSplitPane:"); - add(listTreeLabel, "cell 0 24,aligny top,growy 0"); - - //======== splitPane1 ======== - { - splitPane1.setResizeWeight(0.5); - - //======== scrollPane2 ======== - { - scrollPane2.setPreferredSize(new Dimension(50, 50)); - - //---- list1 ---- - list1.setModel(new AbstractListModel() { - String[] values = { - "Item 1", - "Item 2", - "Item 3" - }; - @Override - public int getSize() { return values.length; } - @Override - public String getElementAt(int i) { return values[i]; } - }); - scrollPane2.setViewportView(list1); - } - splitPane1.setLeftComponent(scrollPane2); - - //======== scrollPane3 ======== - { - scrollPane3.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - scrollPane3.setPreferredSize(new Dimension(50, 50)); - - //---- tree1 ---- - tree1.setModel(new DefaultTreeModel( - new DefaultMutableTreeNode("Item 1") { - { - add(new DefaultMutableTreeNode("Item 2")); - add(new DefaultMutableTreeNode("Item 3")); - } - })); - scrollPane3.setViewportView(tree1); - } - splitPane1.setRightComponent(scrollPane3); - } - add(splitPane1, "cell 1 24,height 50"); - - //---- tableLabel ---- - tableLabel.setText("JTable:"); - add(tableLabel, "cell 0 25"); - - //======== scrollPane4 ======== - { - - //---- table1 ---- - table1.setModel(new DefaultTableModel( - new Object[][] { - {"Item 1a", "Item 1b"}, - {"Item 2a", "Item 2b"}, - }, - new String[] { - "Column 1", "Column 2" - } - )); - scrollPane4.setViewportView(table1); - } - add(scrollPane4, "cell 1 25,height 70"); - - //---- internalFrameLabel ---- - internalFrameLabel.setText("JDesktopPane:
JInternalFrame:"); - add(internalFrameLabel, "cell 0 26,aligny top,growy 0"); - - //======== desktopPane1 ======== - { - - //======== internalFrame1 ======== - { - internalFrame1.setVisible(true); - internalFrame1.setTitle("Active"); - internalFrame1.setClosable(true); - internalFrame1.setMaximizable(true); - internalFrame1.setIconifiable(true); - internalFrame1.setResizable(true); - Container internalFrame1ContentPane = internalFrame1.getContentPane(); - internalFrame1ContentPane.setLayout(new BorderLayout()); - } - desktopPane1.add(internalFrame1, JLayeredPane.DEFAULT_LAYER); - internalFrame1.setBounds(new Rectangle(new Point(5, 5), internalFrame1.getPreferredSize())); - - //======== internalFrame2 ======== - { - internalFrame2.setVisible(true); - internalFrame2.setClosable(true); - internalFrame2.setIconifiable(true); - internalFrame2.setMaximizable(true); - internalFrame2.setResizable(true); - internalFrame2.setTitle("Inactive"); - Container internalFrame2ContentPane = internalFrame2.getContentPane(); - internalFrame2ContentPane.setLayout(new BorderLayout()); - } - desktopPane1.add(internalFrame2, JLayeredPane.DEFAULT_LAYER); - internalFrame2.setBounds(new Rectangle(new Point(5, 50), internalFrame2.getPreferredSize())); - } - add(desktopPane1, "cell 1 26"); - - //---- buttonGroup1 ---- - ButtonGroup buttonGroup1 = new ButtonGroup(); - buttonGroup1.add(radioButton1); - buttonGroup1.add(radioButton3); - - //---- buttonGroup2 ---- - ButtonGroup buttonGroup2 = new ButtonGroup(); - buttonGroup2.add(radioButtonMenuItem4); - buttonGroup2.add(radioButtonMenuItem5); // JFormDesigner - End of component initialization //GEN-END:initComponents } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables + private FlatTabbedPane tabbedPane; private JSeparator previewSeparator; private JLabel previewLabel; - private JCheckBox enabledCheckBox; - private JSeparator separator2; - private JLabel labelLabel; - private JLabel label1; - private FlatButton flatButton1; - private JLabel buttonLabel; - private JButton button1; - private FlatThemePreview.PreviewDefaultButton testDefaultButton1; - private FlatButton helpButton; - private JPanel hSpacer2; - private JLabel toggleButtonLabel; - private JToggleButton toggleButton1; - private JToggleButton toggleButton3; - private JPanel hSpacer1; - private JLabel checkBoxLabel; - private JCheckBox checkBox1; - private JCheckBox checkBox3; - private JPanel hSpacer3; - private JLabel radioButtonLabel; - private JRadioButton radioButton1; - private JRadioButton radioButton3; - private JPanel hSpacer4; - private JLabel comboBoxLabel; - private FlatComboBox comboBox1; - private JComboBox comboBox3; - private JLabel spinnerLabel; - private JSpinner spinner1; - private JLabel textFieldLabel; - private FlatTextField textField1; - private FlatFormattedTextField formattedTextField1; - private FlatPasswordField passwordField1; - private JLabel textAreaLabel; - private JScrollPane scrollPane1; - private JTextArea textArea1; - private JScrollPane scrollPane5; - private JEditorPane editorPane1; - private JScrollPane scrollPane9; - private JTextPane textPane1; - private JLabel menuBarLabel; - private JMenuBar menuBar1; - private JMenu menu2; - private JMenuItem menuItem3; - private JMenuItem menuItem4; - private JCheckBoxMenuItem checkBoxMenuItem2; - private JCheckBoxMenuItem checkBoxMenuItem3; - private JRadioButtonMenuItem radioButtonMenuItem4; - private JRadioButtonMenuItem radioButtonMenuItem5; - private JMenu menu4; - private JMenuItem menuItem6; - private JMenu menu5; - private JMenuItem menuItem7; - private JMenu menu3; - private JMenuItem menuItem5; - private JMenuItem menuItem8; - private JMenuItem menuItem9; - private JLabel scrollBarLabel; - private JScrollBar scrollBar1; - private FlatScrollBar scrollBar5; - private JLabel separatorLabel; - private JSeparator separator1; - private JLabel sliderLabel; - private JSlider slider1; - private JSlider slider3; - private JLabel progressBarLabel; - private FlatProgressBar progressBar1; - private FlatProgressBar progressBar2; - private JLabel toolTipLabel; - private JToolTip toolTip1; - private JLabel toolBarLabel; - private JToolBar toolBar1; - private JButton button4; - private JButton button6; - private JToggleButton button7; - private JToggleButton button8; - private JLabel tabbedPaneLabel; - private FlatThemePreview.PreviewTabbedPane tabbedPane1; - private JLabel listTreeLabel; - private JSplitPane splitPane1; - private JScrollPane scrollPane2; - private JList list1; - private JScrollPane scrollPane3; - private JTree tree1; - private JLabel tableLabel; - private JScrollPane scrollPane4; - private FlatThemePreview.PreviewTable table1; - private JLabel internalFrameLabel; - private JDesktopPane desktopPane1; - private JInternalFrame internalFrame1; - private JInternalFrame internalFrame2; // JFormDesigner - End of variables declaration //GEN-END:variables - //---- class PreviewDefaultButton ----------------------------------------- + //---- class PreviewPanel ------------------------------------------------- - private static class PreviewDefaultButton - extends JButton + private class PreviewPanel + extends JPanel { + PreviewPanel( JComponent c ) { + super( new BorderLayout() ); + add( c ); + } + + @SuppressWarnings( "deprecation" ) @Override - public boolean isDefaultButton() { - return true; - } - } - - //---- class PreviewTabbedPane -------------------------------------------- - - private static class PreviewTabbedPane - extends JTabbedPane - { - Function uiDefaultsGetter; - - @Override - public void updateUI() { - setUI( new PreviewFlatTabbedPaneUI( uiDefaultsGetter ) ); - } - } - - //---- class PreviewFlatTabbedPaneUI -------------------------------------- - - private static class PreviewFlatTabbedPaneUI - extends FlatTabbedPaneUI - { - private final Function uiDefaultsGetter; - - PreviewFlatTabbedPaneUI( Function uiDefaultsGetter ) { - this.uiDefaultsGetter = uiDefaultsGetter; - } - - @Override - protected JButton createMoreTabsButton() { - return new PreviewFlatMoreTabsButton(); - } - - //---- class PreviewFlatMoreTabsButton -------------------------------- - - protected class PreviewFlatMoreTabsButton - extends FlatMoreTabsButton - { - @Override - public void actionPerformed( ActionEvent e ) { - // needed for "more tabs" popup creation - FlatLaf.runWithUIDefaultsGetter( uiDefaultsGetter, () -> { - super.actionPerformed( e ); + public void layout() { + try { + runWithUIDefaultsGetter( () -> { + super.layout(); } ); + } catch( Exception ex ) { + ex.printStackTrace(); } } - } - //---- class PreviewTable ------------------------------------------------- + @Override + protected void validateTree() { + try { + runWithUIDefaultsGetter( () -> { + super.validateTree(); + } ); + } catch( Exception ex ) { + ex.printStackTrace(); + } + } - private static class PreviewTable - extends JTable - { - Function uiDefaultsGetter; + @Override + public Dimension getPreferredSize() { + try { + return super.getPreferredSize(); + } catch( Exception ex ) { + ex.printStackTrace(); + return new Dimension( 100, 100 ); + } + } + + @Override + public Dimension getMinimumSize() { + try { + return super.getMinimumSize(); + } catch( Exception ex ) { + ex.printStackTrace(); + return new Dimension( 100, 100 ); + } + } + + @Override + public Dimension getMaximumSize() { + try { + return super.getMaximumSize(); + } catch( Exception ex ) { + ex.printStackTrace(); + return new Dimension( Short.MAX_VALUE, Short.MAX_VALUE ); + } + } @Override public void paint( Graphics g ) { - // needed for DefaultTableCellRenderer - FlatLaf.runWithUIDefaultsGetter( uiDefaultsGetter, () -> { - super.paint( g ); - } ); + try { + runWithUIDefaultsGetter( () -> { + super.paint( g ); + } ); + } catch( Exception ex ) { + ex.printStackTrace(); + } + } + + @Override + protected void paintComponent( Graphics g ) { + try { + runWithUIDefaultsGetter( () -> { + super.paintComponent( g ); + } ); + } catch( Exception ex ) { + ex.printStackTrace(); + } + } + + @Override + protected void paintChildren( Graphics g ) { + try { + runWithUIDefaultsGetter( () -> { + super.paintChildren( g ); + } ); + } catch( Exception ex ) { + ex.printStackTrace(); + } } } } diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.jfd b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.jfd index f031b2b1..7d1e80a7 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.jfd +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.jfd @@ -3,640 +3,33 @@ JFDML JFormDesigner: "7.0.4.0.360" Java: "16" encoding: "UTF-8" new FormModel { contentType: "form/swing" root: new FormRoot { - add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { - "$layoutConstraints": "insets dialog,hidemode 3" - "$columnConstraints": "[fill][130,fill]" - "$rowConstraints": "[]0[]unrel[][][][][][][][][][][][][][][][][][][][][][][][][100,fill][grow]" - } ) { + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) { name: "this" + add( new FormContainer( "com.formdev.flatlaf.extras.components.FlatTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "tabbedPane" + "leadingComponent": new FormReference( "previewLabel" ) + "tabAreaAlignment": enum com.formdev.flatlaf.extras.components.FlatTabbedPane$TabAreaAlignment trailing + addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "update", false ) ) + }, new FormLayoutConstraints( class java.lang.String ) { + "value": "Center" + } ) add( new FormComponent( "javax.swing.JSeparator" ) { name: "previewSeparator" "orientation": 1 - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "west" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "previewLabel" - "text": "Preview" - "font": new com.jformdesigner.model.SwingDerivedFont( null, 0, 6, false ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 0 2 1,alignx left,growx 0" - } ) - add( new FormComponent( "javax.swing.JCheckBox" ) { - name: "enabledCheckBox" - "text": "Enabled" - "selected": true - addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "enabledChanged", false ) ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 0 2 1,align right top,grow 0 0" - } ) - add( new FormComponent( "javax.swing.JSeparator" ) { - name: "separator2" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 1 2 1" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "labelLabel" - "text": "JLabel:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 2" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "label1" - "text": "Some Text" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 2" - } ) - add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) { - name: "flatButton1" - "text": "Help" - "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType help - "visible": false - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 1,alignx right,growx 0" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "buttonLabel" - "text": "JButton:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 3" - } ) - add( new FormComponent( "javax.swing.JButton" ) { - name: "button1" - "text": "OK" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3,alignx left,growx 0" - } ) - add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreview$PreviewDefaultButton" ) { - name: "testDefaultButton1" - "text": "Default" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" - } ) - add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) { - name: "helpButton" - "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType help - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" - } ) - add( new FormComponent( "com.jformdesigner.designer.wrapper.HSpacer" ) { - name: "hSpacer2" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "toggleButtonLabel" - "text": "JToggleButton:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 4" - } ) - add( new FormComponent( "javax.swing.JToggleButton" ) { - name: "toggleButton1" - "text": "Unselected" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 4,alignx left,growx 0" - } ) - add( new FormComponent( "javax.swing.JToggleButton" ) { - name: "toggleButton3" - "text": "Selected" - "selected": true - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 4" - } ) - add( new FormComponent( "com.jformdesigner.designer.wrapper.HSpacer" ) { - name: "hSpacer1" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 4" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "checkBoxLabel" - "text": "JCheckBox" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 5" - } ) - add( new FormComponent( "javax.swing.JCheckBox" ) { - name: "checkBox1" - "text": "Unselected" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 5,alignx left,growx 0" - } ) - add( new FormComponent( "javax.swing.JCheckBox" ) { - name: "checkBox3" - "text": "Selected" - "selected": true - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 5,alignx left,growx 0" - } ) - add( new FormComponent( "com.jformdesigner.designer.wrapper.HSpacer" ) { - name: "hSpacer3" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 5" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "radioButtonLabel" - "text": "JRadioButton:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 6" - } ) - add( new FormComponent( "javax.swing.JRadioButton" ) { - name: "radioButton1" - "text": "Unselected" - "$buttonGroup": new FormReference( "buttonGroup1" ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 6,alignx left,growx 0" - } ) - add( new FormComponent( "javax.swing.JRadioButton" ) { - name: "radioButton3" - "text": "Selected" - "selected": true - "$buttonGroup": new FormReference( "buttonGroup1" ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 6,alignx left,growx 0" - } ) - add( new FormComponent( "com.jformdesigner.designer.wrapper.HSpacer" ) { - name: "hSpacer4" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 6" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "comboBoxLabel" - "text": "JComboBox:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 7" - } ) - add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatComboBox" ) { - name: "comboBox1" - "editable": true - "model": new javax.swing.DefaultComboBoxModel { - selectedItem: "Editable" - addElement( "Editable" ) - addElement( "a" ) - addElement( "bb" ) - addElement( "ccc" ) - addElement( "dd" ) - addElement( "e" ) - addElement( "ff" ) - addElement( "ggg" ) - addElement( "hh" ) - addElement( "i" ) - addElement( "jj" ) - addElement( "kkk" ) - } - "maximumRowCount": 6 - "placeholderText": "placeholder text" - auxiliary() { - "JavaCodeGenerator.typeParameters": "String" - } - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 7,width 50" - } ) - add( new FormComponent( "javax.swing.JComboBox" ) { - name: "comboBox3" - "model": new javax.swing.DefaultComboBoxModel { - selectedItem: "Not edit" - addElement( "Not edit" ) - addElement( "a" ) - addElement( "bb" ) - addElement( "ccc" ) - addElement( "dd" ) - addElement( "e" ) - addElement( "ff" ) - addElement( "ggg" ) - addElement( "hh" ) - addElement( "i" ) - addElement( "jj" ) - addElement( "kkk" ) - } - "maximumRowCount": 6 - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 7,width 50" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "spinnerLabel" - "text": "JSpinner:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 8" - } ) - add( new FormComponent( "javax.swing.JSpinner" ) { - name: "spinner1" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 8" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "textFieldLabel" - "text": "JTextField:
JFormattedTextF.:
JPasswordField:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 9 1 2" - } ) - add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTextField" ) { - name: "textField1" - "text": "Some Text" - "placeholderText": "placeholder text" - auxiliary() { - "JavaCodeGenerator.variableLocal": false - } - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 9" - } ) - add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatFormattedTextField" ) { - name: "formattedTextField1" - "text": "Some Text" - "placeholderText": "placeholder text" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 10,width 50" - } ) - add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatPasswordField" ) { - name: "passwordField1" - "text": "Some Text" - "placeholderText": "placeholder text" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 10,width 50" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "textAreaLabel" - "text": "JTextArea:

JEditorPane:
JTextPane:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 11 1 2" - } ) - add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { - name: "scrollPane1" - "verticalScrollBarPolicy": 21 - "horizontalScrollBarPolicy": 31 - add( new FormComponent( "javax.swing.JTextArea" ) { - name: "textArea1" - "text": "Some Text" - "rows": 2 - } ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 11" - } ) - add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { - name: "scrollPane5" - "verticalScrollBarPolicy": 21 - "horizontalScrollBarPolicy": 31 - add( new FormComponent( "javax.swing.JEditorPane" ) { - name: "editorPane1" - "text": "Some Text" - } ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 12,width 50" - } ) - add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { - name: "scrollPane9" - "verticalScrollBarPolicy": 21 - "horizontalScrollBarPolicy": 31 - add( new FormComponent( "javax.swing.JTextPane" ) { - name: "textPane1" - "text": "Some Text" - } ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 12,width 50" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "menuBarLabel" - "text": "JMenuBar:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 13" - } ) - add( new FormContainer( "javax.swing.JMenuBar", new FormLayoutManager( class javax.swing.JMenuBar ) ) { - name: "menuBar1" - add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { - name: "menu2" - "text": "JMenu" - add( new FormComponent( "javax.swing.JMenuItem" ) { - name: "menuItem3" - "text": "JMenuItem" - } ) - add( new FormComponent( "javax.swing.JMenuItem" ) { - name: "menuItem4" - "text": "JMenuItem" - } ) - add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) { - name: "separator7" - } ) - add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) { - name: "checkBoxMenuItem2" - "text": "JCheckBoxMenuItem" - "selected": true - } ) - add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) { - name: "checkBoxMenuItem3" - "text": "JCheckBoxMenuItem" - } ) - add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) { - name: "separator9" - } ) - add( new FormComponent( "javax.swing.JRadioButtonMenuItem" ) { - name: "radioButtonMenuItem4" - "text": "JRadioButtonMenuItem" - "$buttonGroup": new FormReference( "buttonGroup2" ) - "selected": true - } ) - add( new FormComponent( "javax.swing.JRadioButtonMenuItem" ) { - name: "radioButtonMenuItem5" - "text": "JRadioButtonMenuItem" - "$buttonGroup": new FormReference( "buttonGroup2" ) - } ) - add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) { - name: "separator3" - } ) - add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { - name: "menu4" - "text": "JMenu" - add( new FormComponent( "javax.swing.JMenuItem" ) { - name: "menuItem6" - "text": "JMenuItem" - } ) - } ) - add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { - name: "menu5" - "text": "JMenu" - add( new FormComponent( "javax.swing.JMenuItem" ) { - name: "menuItem7" - "text": "JMenuItem" - } ) - } ) - } ) - add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { - name: "menu3" - "text": "JMenu" - add( new FormComponent( "javax.swing.JMenuItem" ) { - name: "menuItem5" - "text": "JMenuItem" - } ) - add( new FormComponent( "javax.swing.JMenuItem" ) { - name: "menuItem8" - "text": "JMenuItem" - } ) - add( new FormComponent( "javax.swing.JMenuItem" ) { - name: "menuItem9" - "text": "JMenuItem" - } ) - } ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 13" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "scrollBarLabel" - "text": "JScrollBar:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 14" - } ) - add( new FormComponent( "javax.swing.JScrollBar" ) { - name: "scrollBar1" - "orientation": 0 - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 14" - } ) - add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatScrollBar" ) { - name: "scrollBar5" - "orientation": 0 - "showButtons": true - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 15" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "separatorLabel" - "text": "JSeparator:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 16" - } ) - add( new FormComponent( "javax.swing.JSeparator" ) { - name: "separator1" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 16" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "sliderLabel" - "text": "JSlider:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 17" - } ) - add( new FormComponent( "javax.swing.JSlider" ) { - name: "slider1" - "value": 30 - auxiliary() { - "JavaCodeGenerator.variableLocal": false - } - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 17" - } ) - add( new FormComponent( "javax.swing.JSlider" ) { - name: "slider3" - "minorTickSpacing": 10 - "paintTicks": true - "majorTickSpacing": 50 - "paintLabels": true - "value": 30 - auxiliary() { - "JavaCodeGenerator.variableLocal": false - } - addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "changeProgress", false ) ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 18" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "progressBarLabel" - "text": "JProgressBar:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 19" - } ) - add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatProgressBar" ) { - name: "progressBar1" - "value": 60 - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 19" - } ) - add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatProgressBar" ) { - name: "progressBar2" - "value": 50 - "stringPainted": true - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 20" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "toolTipLabel" - "text": "JToolTip:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 21" - } ) - add( new FormComponent( "javax.swing.JToolTip" ) { - name: "toolTip1" - "tipText": "Some text in tool tip." - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 21,alignx left,growx 0" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "toolBarLabel" - "text": "JToolBar:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 22" - } ) - add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { - name: "toolBar1" - add( new FormComponent( "javax.swing.JButton" ) { - name: "button4" - "icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" ) - } ) - add( new FormComponent( "javax.swing.JButton" ) { - name: "button6" - "icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.openIcon" ) - } ) - add( new FormComponent( "javax.swing.JToolBar$Separator" ) { - name: "separator4" - } ) - add( new FormComponent( "javax.swing.JToggleButton" ) { - name: "button7" - "icon": &SwingIcon0 new com.jformdesigner.model.SwingIcon( 2, "Tree.leafIcon" ) - } ) - add( new FormComponent( "javax.swing.JToggleButton" ) { - name: "button8" - "icon": #SwingIcon0 - "selected": true - } ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 22" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "tabbedPaneLabel" - "text": "JTabbedPane:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 23" - } ) - add( new FormContainer( "com.formdev.flatlaf.themeeditor.FlatThemePreview$PreviewTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { - name: "tabbedPane1" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 23" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "listTreeLabel" - "text": "JList / JTree:
JSplitPane:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 24,aligny top,growy 0" - } ) - add( new FormContainer( "javax.swing.JSplitPane", new FormLayoutManager( class javax.swing.JSplitPane ) ) { - name: "splitPane1" - "resizeWeight": 0.5 - add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { - name: "scrollPane2" - "preferredSize": new java.awt.Dimension( 50, 50 ) - add( new FormComponent( "javax.swing.JList" ) { - name: "list1" - "model": new javax.swing.DefaultListModel { - addElement( "Item 1" ) - addElement( "Item 2" ) - addElement( "Item 3" ) - } - } ) - }, new FormLayoutConstraints( class java.lang.String ) { - "value": "left" - } ) - add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { - name: "scrollPane3" - "horizontalScrollBarPolicy": 31 - "preferredSize": new java.awt.Dimension( 50, 50 ) - add( new FormComponent( "javax.swing.JTree" ) { - name: "tree1" - "model": new javax.swing.tree.DefaultTreeModel( new javax.swing.tree.DefaultMutableTreeNode { - userObject: "Item 1" - add( new javax.swing.tree.DefaultMutableTreeNode { - userObject: "Item 2" - } ) - add( new javax.swing.tree.DefaultMutableTreeNode { - userObject: "Item 3" - } ) - } ) - } ) - }, new FormLayoutConstraints( class java.lang.String ) { - "value": "right" - } ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 24,height 50" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "tableLabel" - "text": "JTable:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 25" - } ) - add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { - name: "scrollPane4" - add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreview$PreviewTable" ) { - name: "table1" - "model": new com.jformdesigner.model.SwingTableModel( new java.util.Vector { - add( new java.util.Vector { - add( "Item 1a" ) - add( "Item 1b" ) - } ) - add( new java.util.Vector { - add( "Item 2a" ) - add( "Item 2b" ) - } ) - }, new java.util.Vector { - add( "Column 1" ) - add( "Column 2" ) - }, new java.util.Vector { - add( null ) - add( null ) - }, new java.util.Vector { - add( null ) - add( null ) - }, new java.util.Vector { - add( null ) - add( null ) - } ) - } ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 25,height 70" - } ) - add( new FormComponent( "javax.swing.JLabel" ) { - name: "internalFrameLabel" - "text": "JDesktopPane:
JInternalFrame:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 26,aligny top,growy 0" - } ) - add( new FormContainer( "javax.swing.JDesktopPane", new FormLayoutManager( class javax.swing.JDesktopPane ) ) { - name: "desktopPane1" - add( new FormContainer( "javax.swing.JInternalFrame", new FormLayoutManager( class java.awt.BorderLayout ) ) { - name: "internalFrame1" - "visible": true - "title": "Active" - "closable": true - "maximizable": true - "iconifiable": true - "resizable": true - }, new FormLayoutConstraints( null ) { - "x": 5 - "y": 5 - } ) - add( new FormContainer( "javax.swing.JInternalFrame", new FormLayoutManager( class java.awt.BorderLayout ) ) { - name: "internalFrame2" - "visible": true - "closable": true - "iconifiable": true - "maximizable": true - "resizable": true - "title": "Inactive" - }, new FormLayoutConstraints( null ) { - "x": 5 - "y": 50 - } ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 26" + }, new FormLayoutConstraints( class java.lang.String ) { + "value": "Before" } ) }, new FormLayoutConstraints( null ) { "location": new java.awt.Point( 0, 0 ) - "size": new java.awt.Dimension( 400, 1070 ) + "size": new java.awt.Dimension( 320, 200 ) } ) - add( new FormNonVisual( "javax.swing.ButtonGroup" ) { - name: "buttonGroup1" + add( new FormComponent( "javax.swing.JLabel" ) { + name: "previewLabel" + "text": " Preview " + "font": new com.jformdesigner.model.SwingDerivedFont( null, 0, 6, false ) }, new FormLayoutConstraints( null ) { - "location": new java.awt.Point( 0, 1095 ) - } ) - add( new FormNonVisual( "javax.swing.ButtonGroup" ) { - name: "buttonGroup2" - }, new FormLayoutConstraints( null ) { - "location": new java.awt.Point( 0, 1145 ) + "location": new java.awt.Point( 0, 235 ) + "size": new java.awt.Dimension( 176, 24 ) } ) } } diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java new file mode 100644 index 00000000..1ab0dcde --- /dev/null +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java @@ -0,0 +1,891 @@ +/* +/* + * Copyright 2021 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.themeeditor; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.beans.PropertyVetoException; +import java.util.function.Function; +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableRowSorter; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import com.formdev.flatlaf.FlatLaf; +import com.formdev.flatlaf.extras.components.*; +import com.formdev.flatlaf.ui.FlatTabbedPaneUI; +import net.miginfocom.swing.*; + +/** + * @author Karl Tauber + */ +class FlatThemePreviewAll + extends JPanel +{ + private final FlatThemePreview preview; + + FlatThemePreviewAll( FlatThemePreview preview ) { + this.preview = preview; + + initComponents(); + + tabbedPane1.uiDefaultsGetter = preview::getUIDefaultProperty; + tabbedPane1.setTabLayoutPolicy( JTabbedPane.SCROLL_TAB_LAYOUT ); + tabbedPane1.addTab( "Tab 1", null ); + tabbedPane1.addTab( "Tab 2", null ); + tabbedPane1.addTab( "Tab 3", null ); + tabbedPane1.addTab( "Tab 4", null ); + tabbedPane1.addTab( "Tab 5", null ); + tabbedPane1.addTab( "Tab 6", null ); + tabbedPane1.addTab( "Tab 7", null ); + tabbedPane1.addTab( "Tab 8", null ); + + list1.setSelectedIndex( 1 ); + tree1.setSelectionRow( 1 ); + table1.setRowSelectionInterval( 1, 1 ); + table1.setRowSorter( new TableRowSorter<>( table1.getModel() ) ); + table1.getRowSorter().toggleSortOrder( 0 ); + table1.uiDefaultsGetter = preview::getUIDefaultProperty; + + EventQueue.invokeLater( () -> { + int width = desktopPane1.getWidth(); + int height = desktopPane1.getHeight() / 2; + internalFrame1.setBounds( 0, 0, width, height ); + internalFrame2.setBounds( 0, height, width, height ); + + try { + internalFrame1.setSelected( true ); + } catch( PropertyVetoException ex ) { + // ignore + } + } ); + } + + private void enabledChanged() { + preview.runWithUIDefaultsGetter( () -> { + enableDisable( this, enabledCheckBox.isSelected() ); + } ); + } + + private void enableDisable( Component comp, boolean enabled ) { + if( comp != enabledCheckBox && comp != menu2 ) + comp.setEnabled( enabled ); + + if( !(comp instanceof Container) || comp instanceof JInternalFrame ) + return; + + for( Component c : ((Container)comp).getComponents() ) { + if( c instanceof JScrollPane ) + c = ((JScrollPane)c).getViewport().getView(); + + // make sure that background is updated correctly in BasicTextUI.updateBackground() + if( c instanceof JTextPane ) + c.setBackground( UIManager.getColor( "TextPane.background" ) ); + else if( c instanceof JEditorPane ) + c.setBackground( UIManager.getColor( "EditorPane.background" ) ); + + enableDisable( c, enabled ); + } + + if( comp instanceof JMenu ) { + JMenu menu = (JMenu) comp; + int count = menu.getMenuComponentCount(); + for( int i = 0; i < count; i++ ) + enableDisable( menu.getMenuComponent( i ), enabled ); + } + } + + private void changeProgress() { + int value = slider3.getValue(); + progressBar1.setValue( value ); + progressBar2.setValue( value ); + } + + private Object toolbarCons; + + @Override + protected void addImpl( Component comp, Object constraints, int index ) { + // if floating toolbar window is closed, then place toolbar at original location + if( comp == toolBar1 ) { + if( toolbarCons == null ) + toolbarCons = constraints; + else if( comp.getParent() == null && toolbarCons != null ) + constraints = toolbarCons; + } + + super.addImpl( comp, constraints, index ); + } + + private void initComponents() { + // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents + enabledCheckBox = new JCheckBox(); + labelLabel = new JLabel(); + label1 = new JLabel(); + flatButton1 = new FlatButton(); + buttonLabel = new JLabel(); + button1 = new JButton(); + testDefaultButton1 = new FlatThemePreviewAll.PreviewDefaultButton(); + helpButton = new FlatButton(); + hSpacer2 = new JPanel(null); + toggleButtonLabel = new JLabel(); + toggleButton1 = new JToggleButton(); + toggleButton3 = new JToggleButton(); + hSpacer1 = new JPanel(null); + checkBoxLabel = new JLabel(); + checkBox1 = new JCheckBox(); + checkBox3 = new JCheckBox(); + hSpacer3 = new JPanel(null); + radioButtonLabel = new JLabel(); + radioButton1 = new JRadioButton(); + radioButton3 = new JRadioButton(); + hSpacer4 = new JPanel(null); + comboBoxLabel = new JLabel(); + comboBox1 = new FlatComboBox<>(); + comboBox3 = new JComboBox<>(); + spinnerLabel = new JLabel(); + spinner1 = new JSpinner(); + textFieldLabel = new JLabel(); + textField1 = new FlatTextField(); + formattedTextField1 = new FlatFormattedTextField(); + passwordField1 = new FlatPasswordField(); + textAreaLabel = new JLabel(); + scrollPane1 = new JScrollPane(); + textArea1 = new JTextArea(); + scrollPane5 = new JScrollPane(); + editorPane1 = new JEditorPane(); + scrollPane9 = new JScrollPane(); + textPane1 = new JTextPane(); + menuBarLabel = new JLabel(); + menuBar1 = new JMenuBar(); + menu2 = new JMenu(); + menuItem3 = new JMenuItem(); + menuItem4 = new JMenuItem(); + checkBoxMenuItem2 = new JCheckBoxMenuItem(); + checkBoxMenuItem3 = new JCheckBoxMenuItem(); + radioButtonMenuItem4 = new JRadioButtonMenuItem(); + radioButtonMenuItem5 = new JRadioButtonMenuItem(); + menu4 = new JMenu(); + menuItem6 = new JMenuItem(); + menu5 = new JMenu(); + menuItem7 = new JMenuItem(); + menu3 = new JMenu(); + menuItem5 = new JMenuItem(); + menuItem8 = new JMenuItem(); + menuItem9 = new JMenuItem(); + scrollBarLabel = new JLabel(); + scrollBar1 = new JScrollBar(); + scrollBar5 = new FlatScrollBar(); + separatorLabel = new JLabel(); + separator1 = new JSeparator(); + sliderLabel = new JLabel(); + slider1 = new JSlider(); + slider3 = new JSlider(); + progressBarLabel = new JLabel(); + progressBar1 = new FlatProgressBar(); + progressBar2 = new FlatProgressBar(); + toolTipLabel = new JLabel(); + toolTip1 = new JToolTip(); + toolBarLabel = new JLabel(); + toolBar1 = new JToolBar(); + button4 = new JButton(); + button6 = new JButton(); + button7 = new JToggleButton(); + button8 = new JToggleButton(); + tabbedPaneLabel = new JLabel(); + tabbedPane1 = new FlatThemePreviewAll.PreviewTabbedPane(); + listTreeLabel = new JLabel(); + splitPane1 = new JSplitPane(); + scrollPane2 = new JScrollPane(); + list1 = new JList<>(); + scrollPane3 = new JScrollPane(); + tree1 = new JTree(); + tableLabel = new JLabel(); + scrollPane4 = new JScrollPane(); + table1 = new FlatThemePreviewAll.PreviewTable(); + internalFrameLabel = new JLabel(); + desktopPane1 = new JDesktopPane(); + internalFrame1 = new JInternalFrame(); + internalFrame2 = new JInternalFrame(); + + //======== this ======== + setLayout(new MigLayout( + "insets dialog,hidemode 3", + // columns + "[fill]" + + "[130,fill]", + // rows + "[]unrel" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[100,fill]" + + "[grow]")); + + //---- enabledCheckBox ---- + enabledCheckBox.setText("Enabled"); + enabledCheckBox.setSelected(true); + enabledCheckBox.addActionListener(e -> enabledChanged()); + add(enabledCheckBox, "cell 0 0 2 1,alignx left,growx 0"); + + //---- labelLabel ---- + labelLabel.setText("JLabel:"); + add(labelLabel, "cell 0 1"); + + //---- label1 ---- + label1.setText("Some Text"); + add(label1, "cell 1 1"); + + //---- flatButton1 ---- + flatButton1.setText("Help"); + flatButton1.setButtonType(FlatButton.ButtonType.help); + flatButton1.setVisible(false); + add(flatButton1, "cell 1 1,alignx right,growx 0"); + + //---- buttonLabel ---- + buttonLabel.setText("JButton:"); + add(buttonLabel, "cell 0 2"); + + //---- button1 ---- + button1.setText("OK"); + add(button1, "cell 1 2,alignx left,growx 0"); + + //---- testDefaultButton1 ---- + testDefaultButton1.setText("Default"); + add(testDefaultButton1, "cell 1 2"); + + //---- helpButton ---- + helpButton.setButtonType(FlatButton.ButtonType.help); + add(helpButton, "cell 1 2"); + add(hSpacer2, "cell 1 2"); + + //---- toggleButtonLabel ---- + toggleButtonLabel.setText("JToggleButton:"); + add(toggleButtonLabel, "cell 0 3"); + + //---- toggleButton1 ---- + toggleButton1.setText("Unselected"); + add(toggleButton1, "cell 1 3,alignx left,growx 0"); + + //---- toggleButton3 ---- + toggleButton3.setText("Selected"); + toggleButton3.setSelected(true); + add(toggleButton3, "cell 1 3"); + add(hSpacer1, "cell 1 3"); + + //---- checkBoxLabel ---- + checkBoxLabel.setText("JCheckBox"); + add(checkBoxLabel, "cell 0 4"); + + //---- checkBox1 ---- + checkBox1.setText("Unselected"); + add(checkBox1, "cell 1 4,alignx left,growx 0"); + + //---- checkBox3 ---- + checkBox3.setText("Selected"); + checkBox3.setSelected(true); + add(checkBox3, "cell 1 4,alignx left,growx 0"); + add(hSpacer3, "cell 1 4"); + + //---- radioButtonLabel ---- + radioButtonLabel.setText("JRadioButton:"); + add(radioButtonLabel, "cell 0 5"); + + //---- radioButton1 ---- + radioButton1.setText("Unselected"); + add(radioButton1, "cell 1 5,alignx left,growx 0"); + + //---- radioButton3 ---- + radioButton3.setText("Selected"); + radioButton3.setSelected(true); + add(radioButton3, "cell 1 5,alignx left,growx 0"); + add(hSpacer4, "cell 1 5"); + + //---- comboBoxLabel ---- + comboBoxLabel.setText("JComboBox:"); + add(comboBoxLabel, "cell 0 6"); + + //---- comboBox1 ---- + comboBox1.setEditable(true); + comboBox1.setModel(new DefaultComboBoxModel<>(new String[] { + "Editable", + "a", + "bb", + "ccc", + "dd", + "e", + "ff", + "ggg", + "hh", + "i", + "jj", + "kkk" + })); + comboBox1.setMaximumRowCount(6); + comboBox1.setPlaceholderText("placeholder text"); + add(comboBox1, "cell 1 6,width 50"); + + //---- comboBox3 ---- + comboBox3.setModel(new DefaultComboBoxModel<>(new String[] { + "Not edit", + "a", + "bb", + "ccc", + "dd", + "e", + "ff", + "ggg", + "hh", + "i", + "jj", + "kkk" + })); + comboBox3.setMaximumRowCount(6); + add(comboBox3, "cell 1 6,width 50"); + + //---- spinnerLabel ---- + spinnerLabel.setText("JSpinner:"); + add(spinnerLabel, "cell 0 7"); + add(spinner1, "cell 1 7"); + + //---- textFieldLabel ---- + textFieldLabel.setText("JTextField:
JFormattedTextF.:
JPasswordField:"); + add(textFieldLabel, "cell 0 8 1 2"); + + //---- textField1 ---- + textField1.setText("Some Text"); + textField1.setPlaceholderText("placeholder text"); + add(textField1, "cell 1 8"); + + //---- formattedTextField1 ---- + formattedTextField1.setText("Some Text"); + formattedTextField1.setPlaceholderText("placeholder text"); + add(formattedTextField1, "cell 1 9,width 50"); + + //---- passwordField1 ---- + passwordField1.setText("Some Text"); + passwordField1.setPlaceholderText("placeholder text"); + add(passwordField1, "cell 1 9,width 50"); + + //---- textAreaLabel ---- + textAreaLabel.setText("JTextArea:

JEditorPane:
JTextPane:"); + add(textAreaLabel, "cell 0 10 1 2"); + + //======== scrollPane1 ======== + { + scrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- textArea1 ---- + textArea1.setText("Some Text"); + textArea1.setRows(2); + scrollPane1.setViewportView(textArea1); + } + add(scrollPane1, "cell 1 10"); + + //======== scrollPane5 ======== + { + scrollPane5.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane5.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- editorPane1 ---- + editorPane1.setText("Some Text"); + scrollPane5.setViewportView(editorPane1); + } + add(scrollPane5, "cell 1 11,width 50"); + + //======== scrollPane9 ======== + { + scrollPane9.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane9.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- textPane1 ---- + textPane1.setText("Some Text"); + scrollPane9.setViewportView(textPane1); + } + add(scrollPane9, "cell 1 11,width 50"); + + //---- menuBarLabel ---- + menuBarLabel.setText("JMenuBar:"); + add(menuBarLabel, "cell 0 12"); + + //======== menuBar1 ======== + { + + //======== menu2 ======== + { + menu2.setText("JMenu"); + + //---- menuItem3 ---- + menuItem3.setText("JMenuItem"); + menu2.add(menuItem3); + + //---- menuItem4 ---- + menuItem4.setText("JMenuItem"); + menu2.add(menuItem4); + menu2.addSeparator(); + + //---- checkBoxMenuItem2 ---- + checkBoxMenuItem2.setText("JCheckBoxMenuItem"); + checkBoxMenuItem2.setSelected(true); + menu2.add(checkBoxMenuItem2); + + //---- checkBoxMenuItem3 ---- + checkBoxMenuItem3.setText("JCheckBoxMenuItem"); + menu2.add(checkBoxMenuItem3); + menu2.addSeparator(); + + //---- radioButtonMenuItem4 ---- + radioButtonMenuItem4.setText("JRadioButtonMenuItem"); + radioButtonMenuItem4.setSelected(true); + menu2.add(radioButtonMenuItem4); + + //---- radioButtonMenuItem5 ---- + radioButtonMenuItem5.setText("JRadioButtonMenuItem"); + menu2.add(radioButtonMenuItem5); + menu2.addSeparator(); + + //======== menu4 ======== + { + menu4.setText("JMenu"); + + //---- menuItem6 ---- + menuItem6.setText("JMenuItem"); + menu4.add(menuItem6); + } + menu2.add(menu4); + + //======== menu5 ======== + { + menu5.setText("JMenu"); + + //---- menuItem7 ---- + menuItem7.setText("JMenuItem"); + menu5.add(menuItem7); + } + menu2.add(menu5); + } + menuBar1.add(menu2); + + //======== menu3 ======== + { + menu3.setText("JMenu"); + + //---- menuItem5 ---- + menuItem5.setText("JMenuItem"); + menu3.add(menuItem5); + + //---- menuItem8 ---- + menuItem8.setText("JMenuItem"); + menu3.add(menuItem8); + + //---- menuItem9 ---- + menuItem9.setText("JMenuItem"); + menu3.add(menuItem9); + } + menuBar1.add(menu3); + } + add(menuBar1, "cell 1 12"); + + //---- scrollBarLabel ---- + scrollBarLabel.setText("JScrollBar:"); + add(scrollBarLabel, "cell 0 13"); + + //---- scrollBar1 ---- + scrollBar1.setOrientation(Adjustable.HORIZONTAL); + add(scrollBar1, "cell 1 13"); + + //---- scrollBar5 ---- + scrollBar5.setOrientation(Adjustable.HORIZONTAL); + scrollBar5.setShowButtons(true); + add(scrollBar5, "cell 1 14"); + + //---- separatorLabel ---- + separatorLabel.setText("JSeparator:"); + add(separatorLabel, "cell 0 15"); + add(separator1, "cell 1 15"); + + //---- sliderLabel ---- + sliderLabel.setText("JSlider:"); + add(sliderLabel, "cell 0 16"); + + //---- slider1 ---- + slider1.setValue(30); + add(slider1, "cell 1 16"); + + //---- slider3 ---- + slider3.setMinorTickSpacing(10); + slider3.setPaintTicks(true); + slider3.setMajorTickSpacing(50); + slider3.setPaintLabels(true); + slider3.setValue(30); + slider3.addChangeListener(e -> changeProgress()); + add(slider3, "cell 1 17"); + + //---- progressBarLabel ---- + progressBarLabel.setText("JProgressBar:"); + add(progressBarLabel, "cell 0 18"); + + //---- progressBar1 ---- + progressBar1.setValue(60); + add(progressBar1, "cell 1 18"); + + //---- progressBar2 ---- + progressBar2.setValue(50); + progressBar2.setStringPainted(true); + add(progressBar2, "cell 1 19"); + + //---- toolTipLabel ---- + toolTipLabel.setText("JToolTip:"); + add(toolTipLabel, "cell 0 20"); + + //---- toolTip1 ---- + toolTip1.setTipText("Some text in tool tip."); + add(toolTip1, "cell 1 20,alignx left,growx 0"); + + //---- toolBarLabel ---- + toolBarLabel.setText("JToolBar:"); + add(toolBarLabel, "cell 0 21"); + + //======== toolBar1 ======== + { + + //---- button4 ---- + button4.setIcon(UIManager.getIcon("Tree.closedIcon")); + toolBar1.add(button4); + + //---- button6 ---- + button6.setIcon(UIManager.getIcon("Tree.openIcon")); + toolBar1.add(button6); + toolBar1.addSeparator(); + + //---- button7 ---- + button7.setIcon(UIManager.getIcon("Tree.leafIcon")); + toolBar1.add(button7); + + //---- button8 ---- + button8.setIcon(UIManager.getIcon("Tree.leafIcon")); + button8.setSelected(true); + toolBar1.add(button8); + } + add(toolBar1, "cell 1 21"); + + //---- tabbedPaneLabel ---- + tabbedPaneLabel.setText("JTabbedPane:"); + add(tabbedPaneLabel, "cell 0 22"); + add(tabbedPane1, "cell 1 22"); + + //---- listTreeLabel ---- + listTreeLabel.setText("JList / JTree:
JSplitPane:"); + add(listTreeLabel, "cell 0 23,aligny top,growy 0"); + + //======== splitPane1 ======== + { + splitPane1.setResizeWeight(0.5); + + //======== scrollPane2 ======== + { + scrollPane2.setPreferredSize(new Dimension(50, 50)); + + //---- list1 ---- + list1.setModel(new AbstractListModel() { + String[] values = { + "Item 1", + "Item 2", + "Item 3" + }; + @Override + public int getSize() { return values.length; } + @Override + public String getElementAt(int i) { return values[i]; } + }); + scrollPane2.setViewportView(list1); + } + splitPane1.setLeftComponent(scrollPane2); + + //======== scrollPane3 ======== + { + scrollPane3.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + scrollPane3.setPreferredSize(new Dimension(50, 50)); + + //---- tree1 ---- + tree1.setModel(new DefaultTreeModel( + new DefaultMutableTreeNode("Item 1") { + { + add(new DefaultMutableTreeNode("Item 2")); + add(new DefaultMutableTreeNode("Item 3")); + } + })); + scrollPane3.setViewportView(tree1); + } + splitPane1.setRightComponent(scrollPane3); + } + add(splitPane1, "cell 1 23,height 50"); + + //---- tableLabel ---- + tableLabel.setText("JTable:"); + add(tableLabel, "cell 0 24"); + + //======== scrollPane4 ======== + { + + //---- table1 ---- + table1.setModel(new DefaultTableModel( + new Object[][] { + {"Item 1a", "Item 1b"}, + {"Item 2a", "Item 2b"}, + }, + new String[] { + "Column 1", "Column 2" + } + )); + scrollPane4.setViewportView(table1); + } + add(scrollPane4, "cell 1 24,height 70"); + + //---- internalFrameLabel ---- + internalFrameLabel.setText("JDesktopPane:
JInternalFrame:"); + add(internalFrameLabel, "cell 0 25,aligny top,growy 0"); + + //======== desktopPane1 ======== + { + + //======== internalFrame1 ======== + { + internalFrame1.setVisible(true); + internalFrame1.setTitle("Active"); + internalFrame1.setClosable(true); + internalFrame1.setMaximizable(true); + internalFrame1.setIconifiable(true); + internalFrame1.setResizable(true); + Container internalFrame1ContentPane = internalFrame1.getContentPane(); + internalFrame1ContentPane.setLayout(new BorderLayout()); + } + desktopPane1.add(internalFrame1, JLayeredPane.DEFAULT_LAYER); + internalFrame1.setBounds(new Rectangle(new Point(5, 5), internalFrame1.getPreferredSize())); + + //======== internalFrame2 ======== + { + internalFrame2.setVisible(true); + internalFrame2.setClosable(true); + internalFrame2.setIconifiable(true); + internalFrame2.setMaximizable(true); + internalFrame2.setResizable(true); + internalFrame2.setTitle("Inactive"); + Container internalFrame2ContentPane = internalFrame2.getContentPane(); + internalFrame2ContentPane.setLayout(new BorderLayout()); + } + desktopPane1.add(internalFrame2, JLayeredPane.DEFAULT_LAYER); + internalFrame2.setBounds(new Rectangle(new Point(5, 50), internalFrame2.getPreferredSize())); + } + add(desktopPane1, "cell 1 25"); + + //---- buttonGroup1 ---- + ButtonGroup buttonGroup1 = new ButtonGroup(); + buttonGroup1.add(radioButton1); + buttonGroup1.add(radioButton3); + + //---- buttonGroup2 ---- + ButtonGroup buttonGroup2 = new ButtonGroup(); + buttonGroup2.add(radioButtonMenuItem4); + buttonGroup2.add(radioButtonMenuItem5); + // JFormDesigner - End of component initialization //GEN-END:initComponents + } + + // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables + private JCheckBox enabledCheckBox; + private JLabel labelLabel; + private JLabel label1; + private FlatButton flatButton1; + private JLabel buttonLabel; + private JButton button1; + private FlatThemePreviewAll.PreviewDefaultButton testDefaultButton1; + private FlatButton helpButton; + private JPanel hSpacer2; + private JLabel toggleButtonLabel; + private JToggleButton toggleButton1; + private JToggleButton toggleButton3; + private JPanel hSpacer1; + private JLabel checkBoxLabel; + private JCheckBox checkBox1; + private JCheckBox checkBox3; + private JPanel hSpacer3; + private JLabel radioButtonLabel; + private JRadioButton radioButton1; + private JRadioButton radioButton3; + private JPanel hSpacer4; + private JLabel comboBoxLabel; + private FlatComboBox comboBox1; + private JComboBox comboBox3; + private JLabel spinnerLabel; + private JSpinner spinner1; + private JLabel textFieldLabel; + private FlatTextField textField1; + private FlatFormattedTextField formattedTextField1; + private FlatPasswordField passwordField1; + private JLabel textAreaLabel; + private JScrollPane scrollPane1; + private JTextArea textArea1; + private JScrollPane scrollPane5; + private JEditorPane editorPane1; + private JScrollPane scrollPane9; + private JTextPane textPane1; + private JLabel menuBarLabel; + private JMenuBar menuBar1; + private JMenu menu2; + private JMenuItem menuItem3; + private JMenuItem menuItem4; + private JCheckBoxMenuItem checkBoxMenuItem2; + private JCheckBoxMenuItem checkBoxMenuItem3; + private JRadioButtonMenuItem radioButtonMenuItem4; + private JRadioButtonMenuItem radioButtonMenuItem5; + private JMenu menu4; + private JMenuItem menuItem6; + private JMenu menu5; + private JMenuItem menuItem7; + private JMenu menu3; + private JMenuItem menuItem5; + private JMenuItem menuItem8; + private JMenuItem menuItem9; + private JLabel scrollBarLabel; + private JScrollBar scrollBar1; + private FlatScrollBar scrollBar5; + private JLabel separatorLabel; + private JSeparator separator1; + private JLabel sliderLabel; + private JSlider slider1; + private JSlider slider3; + private JLabel progressBarLabel; + private FlatProgressBar progressBar1; + private FlatProgressBar progressBar2; + private JLabel toolTipLabel; + private JToolTip toolTip1; + private JLabel toolBarLabel; + private JToolBar toolBar1; + private JButton button4; + private JButton button6; + private JToggleButton button7; + private JToggleButton button8; + private JLabel tabbedPaneLabel; + private FlatThemePreviewAll.PreviewTabbedPane tabbedPane1; + private JLabel listTreeLabel; + private JSplitPane splitPane1; + private JScrollPane scrollPane2; + private JList list1; + private JScrollPane scrollPane3; + private JTree tree1; + private JLabel tableLabel; + private JScrollPane scrollPane4; + private FlatThemePreviewAll.PreviewTable table1; + private JLabel internalFrameLabel; + private JDesktopPane desktopPane1; + private JInternalFrame internalFrame1; + private JInternalFrame internalFrame2; + // JFormDesigner - End of variables declaration //GEN-END:variables + + //---- class PreviewDefaultButton ----------------------------------------- + + private static class PreviewDefaultButton + extends JButton + { + @Override + public boolean isDefaultButton() { + return true; + } + } + + //---- class PreviewTabbedPane -------------------------------------------- + + private static class PreviewTabbedPane + extends JTabbedPane + { + Function uiDefaultsGetter; + + @Override + public void updateUI() { + setUI( new PreviewFlatTabbedPaneUI( uiDefaultsGetter ) ); + } + } + + //---- class PreviewFlatTabbedPaneUI -------------------------------------- + + private static class PreviewFlatTabbedPaneUI + extends FlatTabbedPaneUI + { + private final Function uiDefaultsGetter; + + PreviewFlatTabbedPaneUI( Function uiDefaultsGetter ) { + this.uiDefaultsGetter = uiDefaultsGetter; + } + + @Override + protected JButton createMoreTabsButton() { + return new PreviewFlatMoreTabsButton(); + } + + //---- class PreviewFlatMoreTabsButton -------------------------------- + + protected class PreviewFlatMoreTabsButton + extends FlatMoreTabsButton + { + @Override + public void actionPerformed( ActionEvent e ) { + // needed for "more tabs" popup creation + FlatLaf.runWithUIDefaultsGetter( uiDefaultsGetter, () -> { + super.actionPerformed( e ); + } ); + } + } + } + + //---- class PreviewTable ------------------------------------------------- + + private static class PreviewTable + extends JTable + { + Function uiDefaultsGetter; + + @Override + public void paint( Graphics g ) { + // needed for DefaultTableCellRenderer + FlatLaf.runWithUIDefaultsGetter( uiDefaultsGetter, () -> { + super.paint( g ); + } ); + } + } +} diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.jfd b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.jfd new file mode 100644 index 00000000..563a63bb --- /dev/null +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.jfd @@ -0,0 +1,624 @@ +JFDML JFormDesigner: "7.0.4.0.360" Java: "16" encoding: "UTF-8" + +new FormModel { + contentType: "form/swing" + root: new FormRoot { + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "insets dialog,hidemode 3" + "$columnConstraints": "[fill][130,fill]" + "$rowConstraints": "[]unrel[][][][][][][][][][][][][][][][][][][][][][][][][100,fill][grow]" + } ) { + name: "this" + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "enabledCheckBox" + "text": "Enabled" + "selected": true + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "enabledChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0 2 1,alignx left,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "labelLabel" + "text": "JLabel:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label1" + "text": "Some Text" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 1" + } ) + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) { + name: "flatButton1" + "text": "Help" + "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType help + "visible": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 1,alignx right,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "buttonLabel" + "text": "JButton:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 2" + } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "button1" + "text": "OK" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 2,alignx left,growx 0" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewAll$PreviewDefaultButton" ) { + name: "testDefaultButton1" + "text": "Default" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 2" + } ) + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) { + name: "helpButton" + "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType help + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 2" + } ) + add( new FormComponent( "com.jformdesigner.designer.wrapper.HSpacer" ) { + name: "hSpacer2" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 2" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "toggleButtonLabel" + "text": "JToggleButton:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 3" + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "toggleButton1" + "text": "Unselected" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 3,alignx left,growx 0" + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "toggleButton3" + "text": "Selected" + "selected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 3" + } ) + add( new FormComponent( "com.jformdesigner.designer.wrapper.HSpacer" ) { + name: "hSpacer1" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 3" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "checkBoxLabel" + "text": "JCheckBox" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 4" + } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "checkBox1" + "text": "Unselected" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 4,alignx left,growx 0" + } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "checkBox3" + "text": "Selected" + "selected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 4,alignx left,growx 0" + } ) + add( new FormComponent( "com.jformdesigner.designer.wrapper.HSpacer" ) { + name: "hSpacer3" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 4" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "radioButtonLabel" + "text": "JRadioButton:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 5" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "radioButton1" + "text": "Unselected" + "$buttonGroup": new FormReference( "buttonGroup1" ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 5,alignx left,growx 0" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "radioButton3" + "text": "Selected" + "selected": true + "$buttonGroup": new FormReference( "buttonGroup1" ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 5,alignx left,growx 0" + } ) + add( new FormComponent( "com.jformdesigner.designer.wrapper.HSpacer" ) { + name: "hSpacer4" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 5" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "comboBoxLabel" + "text": "JComboBox:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 6" + } ) + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatComboBox" ) { + name: "comboBox1" + "editable": true + "model": new javax.swing.DefaultComboBoxModel { + selectedItem: "Editable" + addElement( "Editable" ) + addElement( "a" ) + addElement( "bb" ) + addElement( "ccc" ) + addElement( "dd" ) + addElement( "e" ) + addElement( "ff" ) + addElement( "ggg" ) + addElement( "hh" ) + addElement( "i" ) + addElement( "jj" ) + addElement( "kkk" ) + } + "maximumRowCount": 6 + "placeholderText": "placeholder text" + auxiliary() { + "JavaCodeGenerator.typeParameters": "String" + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 6,width 50" + } ) + add( new FormComponent( "javax.swing.JComboBox" ) { + name: "comboBox3" + "model": new javax.swing.DefaultComboBoxModel { + selectedItem: "Not edit" + addElement( "Not edit" ) + addElement( "a" ) + addElement( "bb" ) + addElement( "ccc" ) + addElement( "dd" ) + addElement( "e" ) + addElement( "ff" ) + addElement( "ggg" ) + addElement( "hh" ) + addElement( "i" ) + addElement( "jj" ) + addElement( "kkk" ) + } + "maximumRowCount": 6 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 6,width 50" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "spinnerLabel" + "text": "JSpinner:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 7" + } ) + add( new FormComponent( "javax.swing.JSpinner" ) { + name: "spinner1" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 7" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "textFieldLabel" + "text": "JTextField:
JFormattedTextF.:
JPasswordField:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 8 1 2" + } ) + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTextField" ) { + name: "textField1" + "text": "Some Text" + "placeholderText": "placeholder text" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 8" + } ) + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatFormattedTextField" ) { + name: "formattedTextField1" + "text": "Some Text" + "placeholderText": "placeholder text" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 9,width 50" + } ) + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatPasswordField" ) { + name: "passwordField1" + "text": "Some Text" + "placeholderText": "placeholder text" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 9,width 50" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "textAreaLabel" + "text": "JTextArea:

JEditorPane:
JTextPane:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 10 1 2" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane1" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JTextArea" ) { + name: "textArea1" + "text": "Some Text" + "rows": 2 + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 10" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane5" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JEditorPane" ) { + name: "editorPane1" + "text": "Some Text" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 11,width 50" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane9" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JTextPane" ) { + name: "textPane1" + "text": "Some Text" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 11,width 50" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "menuBarLabel" + "text": "JMenuBar:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 12" + } ) + add( new FormContainer( "javax.swing.JMenuBar", new FormLayoutManager( class javax.swing.JMenuBar ) ) { + name: "menuBar1" + add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { + name: "menu2" + "text": "JMenu" + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "menuItem3" + "text": "JMenuItem" + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "menuItem4" + "text": "JMenuItem" + } ) + add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) { + name: "separator7" + } ) + add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) { + name: "checkBoxMenuItem2" + "text": "JCheckBoxMenuItem" + "selected": true + } ) + add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) { + name: "checkBoxMenuItem3" + "text": "JCheckBoxMenuItem" + } ) + add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) { + name: "separator9" + } ) + add( new FormComponent( "javax.swing.JRadioButtonMenuItem" ) { + name: "radioButtonMenuItem4" + "text": "JRadioButtonMenuItem" + "$buttonGroup": new FormReference( "buttonGroup2" ) + "selected": true + } ) + add( new FormComponent( "javax.swing.JRadioButtonMenuItem" ) { + name: "radioButtonMenuItem5" + "text": "JRadioButtonMenuItem" + "$buttonGroup": new FormReference( "buttonGroup2" ) + } ) + add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) { + name: "separator3" + } ) + add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { + name: "menu4" + "text": "JMenu" + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "menuItem6" + "text": "JMenuItem" + } ) + } ) + add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { + name: "menu5" + "text": "JMenu" + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "menuItem7" + "text": "JMenuItem" + } ) + } ) + } ) + add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { + name: "menu3" + "text": "JMenu" + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "menuItem5" + "text": "JMenuItem" + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "menuItem8" + "text": "JMenuItem" + } ) + add( new FormComponent( "javax.swing.JMenuItem" ) { + name: "menuItem9" + "text": "JMenuItem" + } ) + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 12" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "scrollBarLabel" + "text": "JScrollBar:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 13" + } ) + add( new FormComponent( "javax.swing.JScrollBar" ) { + name: "scrollBar1" + "orientation": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 13" + } ) + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatScrollBar" ) { + name: "scrollBar5" + "orientation": 0 + "showButtons": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 14" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "separatorLabel" + "text": "JSeparator:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 15" + } ) + add( new FormComponent( "javax.swing.JSeparator" ) { + name: "separator1" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 15" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "sliderLabel" + "text": "JSlider:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 16" + } ) + add( new FormComponent( "javax.swing.JSlider" ) { + name: "slider1" + "value": 30 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 16" + } ) + add( new FormComponent( "javax.swing.JSlider" ) { + name: "slider3" + "minorTickSpacing": 10 + "paintTicks": true + "majorTickSpacing": 50 + "paintLabels": true + "value": 30 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "changeProgress", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 17" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "progressBarLabel" + "text": "JProgressBar:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 18" + } ) + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatProgressBar" ) { + name: "progressBar1" + "value": 60 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 18" + } ) + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatProgressBar" ) { + name: "progressBar2" + "value": 50 + "stringPainted": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 19" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "toolTipLabel" + "text": "JToolTip:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 20" + } ) + add( new FormComponent( "javax.swing.JToolTip" ) { + name: "toolTip1" + "tipText": "Some text in tool tip." + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 20,alignx left,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "toolBarLabel" + "text": "JToolBar:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 21" + } ) + add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { + name: "toolBar1" + add( new FormComponent( "javax.swing.JButton" ) { + name: "button4" + "icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" ) + } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "button6" + "icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.openIcon" ) + } ) + add( new FormComponent( "javax.swing.JToolBar$Separator" ) { + name: "separator4" + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "button7" + "icon": &SwingIcon0 new com.jformdesigner.model.SwingIcon( 2, "Tree.leafIcon" ) + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "button8" + "icon": #SwingIcon0 + "selected": true + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 21" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "tabbedPaneLabel" + "text": "JTabbedPane:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 22" + } ) + add( new FormContainer( "com.formdev.flatlaf.themeeditor.FlatThemePreviewAll$PreviewTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "tabbedPane1" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 22" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "listTreeLabel" + "text": "JList / JTree:
JSplitPane:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 23,aligny top,growy 0" + } ) + add( new FormContainer( "javax.swing.JSplitPane", new FormLayoutManager( class javax.swing.JSplitPane ) ) { + name: "splitPane1" + "resizeWeight": 0.5 + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane2" + "preferredSize": new java.awt.Dimension( 50, 50 ) + add( new FormComponent( "javax.swing.JList" ) { + name: "list1" + "model": new javax.swing.DefaultListModel { + addElement( "Item 1" ) + addElement( "Item 2" ) + addElement( "Item 3" ) + } + } ) + }, new FormLayoutConstraints( class java.lang.String ) { + "value": "left" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane3" + "horizontalScrollBarPolicy": 31 + "preferredSize": new java.awt.Dimension( 50, 50 ) + add( new FormComponent( "javax.swing.JTree" ) { + name: "tree1" + "model": new javax.swing.tree.DefaultTreeModel( new javax.swing.tree.DefaultMutableTreeNode { + userObject: "Item 1" + add( new javax.swing.tree.DefaultMutableTreeNode { + userObject: "Item 2" + } ) + add( new javax.swing.tree.DefaultMutableTreeNode { + userObject: "Item 3" + } ) + } ) + } ) + }, new FormLayoutConstraints( class java.lang.String ) { + "value": "right" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 23,height 50" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "tableLabel" + "text": "JTable:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 24" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane4" + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewAll$PreviewTable" ) { + name: "table1" + "model": new com.jformdesigner.model.SwingTableModel( new java.util.Vector { + add( new java.util.Vector { + add( "Item 1a" ) + add( "Item 1b" ) + } ) + add( new java.util.Vector { + add( "Item 2a" ) + add( "Item 2b" ) + } ) + }, new java.util.Vector { + add( "Column 1" ) + add( "Column 2" ) + }, new java.util.Vector { + add( null ) + add( null ) + }, new java.util.Vector { + add( null ) + add( null ) + }, new java.util.Vector { + add( null ) + add( null ) + } ) + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 24,height 70" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "internalFrameLabel" + "text": "JDesktopPane:
JInternalFrame:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 25,aligny top,growy 0" + } ) + add( new FormContainer( "javax.swing.JDesktopPane", new FormLayoutManager( class javax.swing.JDesktopPane ) ) { + name: "desktopPane1" + add( new FormContainer( "javax.swing.JInternalFrame", new FormLayoutManager( class java.awt.BorderLayout ) ) { + name: "internalFrame1" + "visible": true + "title": "Active" + "closable": true + "maximizable": true + "iconifiable": true + "resizable": true + }, new FormLayoutConstraints( null ) { + "x": 5 + "y": 5 + } ) + add( new FormContainer( "javax.swing.JInternalFrame", new FormLayoutManager( class java.awt.BorderLayout ) ) { + name: "internalFrame2" + "visible": true + "closable": true + "iconifiable": true + "maximizable": true + "resizable": true + "title": "Inactive" + }, new FormLayoutConstraints( null ) { + "x": 5 + "y": 50 + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 25" + } ) + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 0 ) + "size": new java.awt.Dimension( 400, 1070 ) + } ) + add( new FormNonVisual( "javax.swing.ButtonGroup" ) { + name: "buttonGroup1" + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 1095 ) + } ) + add( new FormNonVisual( "javax.swing.ButtonGroup" ) { + name: "buttonGroup2" + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 1145 ) + } ) + } +} diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.java new file mode 100644 index 00000000..611876fb --- /dev/null +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.java @@ -0,0 +1,705 @@ +/* + * Copyright 2021 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.themeeditor; + +import java.util.function.Predicate; +import javax.swing.*; +import com.formdev.flatlaf.FlatClientProperties; +import net.miginfocom.swing.*; + +/** + * @author Karl Tauber + */ +class FlatThemePreviewButtons + extends JPanel +{ + FlatThemePreviewButtons() { + initComponents(); + } + + private void initComponents() { + // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents + label11 = new JLabel(); + label5 = new JLabel(); + label7 = new JLabel(); + label6 = new JLabel(); + label8 = new JLabel(); + label1 = new JLabel(); + testStateButton1 = new FlatThemePreviewButtons.TestStateButton(); + testStateButton7 = new FlatThemePreviewButtons.TestStateButton(); + testStateButton4 = new FlatThemePreviewButtons.TestStateButton(); + testStateButton10 = new FlatThemePreviewButtons.TestStateButton(); + label2 = new JLabel(); + testStateButton2 = new FlatThemePreviewButtons.TestStateButton(); + testStateButton8 = new FlatThemePreviewButtons.TestStateButton(); + testStateButton5 = new FlatThemePreviewButtons.TestStateButton(); + testStateButton11 = new FlatThemePreviewButtons.TestStateButton(); + label3 = new JLabel(); + testStateButton3 = new FlatThemePreviewButtons.TestStateButton(); + testStateButton9 = new FlatThemePreviewButtons.TestStateButton(); + testStateButton6 = new FlatThemePreviewButtons.TestStateButton(); + testStateButton12 = new FlatThemePreviewButtons.TestStateButton(); + label4 = new JLabel(); + testStateButton13 = new FlatThemePreviewButtons.TestStateButton(); + testStateButton14 = new FlatThemePreviewButtons.TestStateButton(); + label10 = new JLabel(); + button1 = new JButton(); + testDefaultButton1 = new FlatThemePreviewButtons.TestDefaultButton(); + label12 = new JLabel(); + label13 = new JLabel(); + label14 = new JLabel(); + label15 = new JLabel(); + label16 = new JLabel(); + label17 = new JLabel(); + testStateToggleButton1 = new FlatThemePreviewButtons.TestStateToggleButton(); + testStateToggleButton5 = new FlatThemePreviewButtons.TestStateToggleButton(); + testStateToggleButton9 = new FlatThemePreviewButtons.TestStateToggleButton(); + testStateToggleButton12 = new FlatThemePreviewButtons.TestStateToggleButton(); + label18 = new JLabel(); + testStateToggleButton2 = new FlatThemePreviewButtons.TestStateToggleButton(); + testStateToggleButton6 = new FlatThemePreviewButtons.TestStateToggleButton(); + testStateToggleButton10 = new FlatThemePreviewButtons.TestStateToggleButton(); + testStateToggleButton13 = new FlatThemePreviewButtons.TestStateToggleButton(); + label19 = new JLabel(); + testStateToggleButton3 = new FlatThemePreviewButtons.TestStateToggleButton(); + testStateToggleButton7 = new FlatThemePreviewButtons.TestStateToggleButton(); + testStateToggleButton11 = new FlatThemePreviewButtons.TestStateToggleButton(); + testStateToggleButton14 = new FlatThemePreviewButtons.TestStateToggleButton(); + label20 = new JLabel(); + testStateToggleButton4 = new FlatThemePreviewButtons.TestStateToggleButton(); + testStateToggleButton8 = new FlatThemePreviewButtons.TestStateToggleButton(); + label21 = new JLabel(); + toggleButton1 = new JToggleButton(); + toggleButton2 = new JToggleButton(); + label32 = new JLabel(); + label9 = new JLabel(); + label33 = new JLabel(); + label22 = new JLabel(); + testStateButton15 = new FlatThemePreviewButtons.TestStateButton(); + testStateButton19 = new FlatThemePreviewButtons.TestStateButton(); + label23 = new JLabel(); + testStateButton16 = new FlatThemePreviewButtons.TestStateButton(); + testStateButton20 = new FlatThemePreviewButtons.TestStateButton(); + label24 = new JLabel(); + testStateButton17 = new FlatThemePreviewButtons.TestStateButton(); + testStateButton21 = new FlatThemePreviewButtons.TestStateButton(); + label25 = new JLabel(); + testStateButton18 = new FlatThemePreviewButtons.TestStateButton(); + label26 = new JLabel(); + button2 = new JButton(); + + //======== this ======== + setLayout(new MigLayout( + "insets dialog,hidemode 3", + // columns + "[fill]" + + "[fill]" + + "[fill]para" + + "[fill]" + + "[fill]para", + // rows + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]unrel" + + "[]para" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]unrel" + + "[]para" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]unrel" + + "[]")); + + //---- label11 ---- + label11.setText("JButton"); + label11.setFont(label11.getFont().deriveFont(label11.getFont().getSize() + 4f)); + add(label11, "cell 0 0 3 1"); + + //---- label5 ---- + label5.setText("regular"); + add(label5, "cell 1 1"); + + //---- label7 ---- + label7.setText("default"); + add(label7, "cell 2 1"); + + //---- label6 ---- + label6.setText("focused"); + add(label6, "cell 3 1"); + + //---- label8 ---- + label8.setText("default"); + add(label8, "cell 4 1"); + + //---- label1 ---- + label1.setText("none"); + add(label1, "cell 0 2"); + + //---- testStateButton1 ---- + testStateButton1.setText("OK"); + testStateButton1.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton1, "cell 1 2"); + + //---- testStateButton7 ---- + testStateButton7.setText("OK"); + testStateButton7.setStateDefault(true); + testStateButton7.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton7, "cell 2 2"); + + //---- testStateButton4 ---- + testStateButton4.setText("OK"); + testStateButton4.setStateFocused(true); + testStateButton4.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton4, "cell 3 2"); + + //---- testStateButton10 ---- + testStateButton10.setText("OK"); + testStateButton10.setStateFocused(true); + testStateButton10.setStateDefault(true); + testStateButton10.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton10, "cell 4 2"); + + //---- label2 ---- + label2.setText("hover"); + add(label2, "cell 0 3"); + + //---- testStateButton2 ---- + testStateButton2.setText("OK"); + testStateButton2.setStateHover(true); + testStateButton2.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton2, "cell 1 3"); + + //---- testStateButton8 ---- + testStateButton8.setText("OK"); + testStateButton8.setStateHover(true); + testStateButton8.setStateDefault(true); + testStateButton8.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton8, "cell 2 3"); + + //---- testStateButton5 ---- + testStateButton5.setText("OK"); + testStateButton5.setStateHover(true); + testStateButton5.setStateFocused(true); + testStateButton5.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton5, "cell 3 3"); + + //---- testStateButton11 ---- + testStateButton11.setText("OK"); + testStateButton11.setStateHover(true); + testStateButton11.setStateFocused(true); + testStateButton11.setStateDefault(true); + testStateButton11.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton11, "cell 4 3"); + + //---- label3 ---- + label3.setText("pressed"); + add(label3, "cell 0 4"); + + //---- testStateButton3 ---- + testStateButton3.setText("OK"); + testStateButton3.setStatePressed(true); + testStateButton3.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton3, "cell 1 4"); + + //---- testStateButton9 ---- + testStateButton9.setText("OK"); + testStateButton9.setStatePressed(true); + testStateButton9.setStateDefault(true); + testStateButton9.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton9, "cell 2 4"); + + //---- testStateButton6 ---- + testStateButton6.setText("OK"); + testStateButton6.setStatePressed(true); + testStateButton6.setStateFocused(true); + testStateButton6.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton6, "cell 3 4"); + + //---- testStateButton12 ---- + testStateButton12.setText("OK"); + testStateButton12.setStatePressed(true); + testStateButton12.setStateFocused(true); + testStateButton12.setStateDefault(true); + testStateButton12.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton12, "cell 4 4"); + + //---- label4 ---- + label4.setText("disabled"); + add(label4, "cell 0 5"); + + //---- testStateButton13 ---- + testStateButton13.setText("OK"); + testStateButton13.setEnabled(false); + testStateButton13.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton13, "cell 1 5"); + + //---- testStateButton14 ---- + testStateButton14.setText("OK"); + testStateButton14.setEnabled(false); + testStateButton14.setStateDefault(true); + testStateButton14.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton14, "cell 2 5"); + + //---- label10 ---- + label10.setText("try me"); + add(label10, "cell 0 6"); + + //---- button1 ---- + button1.setText("OK"); + button1.putClientProperty("JComponent.minimumWidth", 0); + add(button1, "cell 1 6"); + + //---- testDefaultButton1 ---- + testDefaultButton1.setText("OK"); + testDefaultButton1.putClientProperty("JComponent.minimumWidth", 0); + add(testDefaultButton1, "cell 2 6"); + + //---- label12 ---- + label12.setText("JToggleButton"); + label12.setFont(label12.getFont().deriveFont(label12.getFont().getSize() + 4f)); + add(label12, "cell 0 7 3 1"); + + //---- label13 ---- + label13.setText("unsel."); + add(label13, "cell 1 8"); + + //---- label14 ---- + label14.setText("selected"); + add(label14, "cell 2 8"); + + //---- label15 ---- + label15.setText("focused"); + add(label15, "cell 3 8"); + + //---- label16 ---- + label16.setText("selected"); + add(label16, "cell 4 8"); + + //---- label17 ---- + label17.setText("none"); + add(label17, "cell 0 9"); + + //---- testStateToggleButton1 ---- + testStateToggleButton1.setText("OK"); + add(testStateToggleButton1, "cell 1 9"); + + //---- testStateToggleButton5 ---- + testStateToggleButton5.setText("OK"); + testStateToggleButton5.setStateSelected(true); + add(testStateToggleButton5, "cell 2 9"); + + //---- testStateToggleButton9 ---- + testStateToggleButton9.setText("OK"); + testStateToggleButton9.setStateFocused(true); + add(testStateToggleButton9, "cell 3 9"); + + //---- testStateToggleButton12 ---- + testStateToggleButton12.setText("OK"); + testStateToggleButton12.setStateSelected(true); + testStateToggleButton12.setStateFocused(true); + add(testStateToggleButton12, "cell 4 9"); + + //---- label18 ---- + label18.setText("hover"); + add(label18, "cell 0 10"); + + //---- testStateToggleButton2 ---- + testStateToggleButton2.setText("OK"); + testStateToggleButton2.setStateHover(true); + add(testStateToggleButton2, "cell 1 10"); + + //---- testStateToggleButton6 ---- + testStateToggleButton6.setText("OK"); + testStateToggleButton6.setStateHover(true); + testStateToggleButton6.setStateSelected(true); + add(testStateToggleButton6, "cell 2 10"); + + //---- testStateToggleButton10 ---- + testStateToggleButton10.setText("OK"); + testStateToggleButton10.setStateHover(true); + testStateToggleButton10.setStateFocused(true); + add(testStateToggleButton10, "cell 3 10"); + + //---- testStateToggleButton13 ---- + testStateToggleButton13.setText("OK"); + testStateToggleButton13.setStateHover(true); + testStateToggleButton13.setStateSelected(true); + testStateToggleButton13.setStateFocused(true); + add(testStateToggleButton13, "cell 4 10"); + + //---- label19 ---- + label19.setText("pressed"); + add(label19, "cell 0 11"); + + //---- testStateToggleButton3 ---- + testStateToggleButton3.setText("OK"); + testStateToggleButton3.setStatePressed(true); + add(testStateToggleButton3, "cell 1 11"); + + //---- testStateToggleButton7 ---- + testStateToggleButton7.setText("OK"); + testStateToggleButton7.setStatePressed(true); + testStateToggleButton7.setStateSelected(true); + add(testStateToggleButton7, "cell 2 11"); + + //---- testStateToggleButton11 ---- + testStateToggleButton11.setText("OK"); + testStateToggleButton11.setStatePressed(true); + testStateToggleButton11.setStateFocused(true); + add(testStateToggleButton11, "cell 3 11"); + + //---- testStateToggleButton14 ---- + testStateToggleButton14.setText("OK"); + testStateToggleButton14.setStatePressed(true); + testStateToggleButton14.setStateSelected(true); + testStateToggleButton14.setStateFocused(true); + add(testStateToggleButton14, "cell 4 11"); + + //---- label20 ---- + label20.setText("disabled"); + add(label20, "cell 0 12"); + + //---- testStateToggleButton4 ---- + testStateToggleButton4.setText("OK"); + testStateToggleButton4.setEnabled(false); + add(testStateToggleButton4, "cell 1 12"); + + //---- testStateToggleButton8 ---- + testStateToggleButton8.setText("OK"); + testStateToggleButton8.setEnabled(false); + testStateToggleButton8.setStateSelected(true); + add(testStateToggleButton8, "cell 2 12"); + + //---- label21 ---- + label21.setText("try me"); + add(label21, "cell 0 13"); + + //---- toggleButton1 ---- + toggleButton1.setText("OK"); + add(toggleButton1, "cell 1 13"); + + //---- toggleButton2 ---- + toggleButton2.setText("OK"); + toggleButton2.setSelected(true); + add(toggleButton2, "cell 2 13"); + + //---- label32 ---- + label32.setText("Help Button"); + label32.setFont(label32.getFont().deriveFont(label32.getFont().getSize() + 4f)); + add(label32, "cell 0 14 2 1"); + + //---- label9 ---- + label9.setText("regular"); + add(label9, "cell 1 15"); + + //---- label33 ---- + label33.setText("focused"); + add(label33, "cell 2 15"); + + //---- label22 ---- + label22.setText("none"); + add(label22, "cell 0 16"); + + //---- testStateButton15 ---- + testStateButton15.putClientProperty("JComponent.minimumWidth", 0); + testStateButton15.putClientProperty("JButton.buttonType", "help"); + add(testStateButton15, "cell 1 16"); + + //---- testStateButton19 ---- + testStateButton19.setStateFocused(true); + testStateButton19.putClientProperty("JComponent.minimumWidth", 0); + testStateButton19.putClientProperty("JButton.buttonType", "help"); + add(testStateButton19, "cell 2 16"); + + //---- label23 ---- + label23.setText("hover"); + add(label23, "cell 0 17"); + + //---- testStateButton16 ---- + testStateButton16.setStateHover(true); + testStateButton16.putClientProperty("JComponent.minimumWidth", 0); + testStateButton16.putClientProperty("JButton.buttonType", "help"); + add(testStateButton16, "cell 1 17"); + + //---- testStateButton20 ---- + testStateButton20.setStateHover(true); + testStateButton20.setStateFocused(true); + testStateButton20.putClientProperty("JComponent.minimumWidth", 0); + testStateButton20.putClientProperty("JButton.buttonType", "help"); + add(testStateButton20, "cell 2 17"); + + //---- label24 ---- + label24.setText("pressed"); + add(label24, "cell 0 18"); + + //---- testStateButton17 ---- + testStateButton17.setStatePressed(true); + testStateButton17.putClientProperty("JComponent.minimumWidth", 0); + testStateButton17.putClientProperty("JButton.buttonType", "help"); + add(testStateButton17, "cell 1 18"); + + //---- testStateButton21 ---- + testStateButton21.setStatePressed(true); + testStateButton21.setStateFocused(true); + testStateButton21.putClientProperty("JComponent.minimumWidth", 0); + testStateButton21.putClientProperty("JButton.buttonType", "help"); + add(testStateButton21, "cell 2 18"); + + //---- label25 ---- + label25.setText("disabled"); + add(label25, "cell 0 19"); + + //---- testStateButton18 ---- + testStateButton18.setEnabled(false); + testStateButton18.putClientProperty("JComponent.minimumWidth", 0); + testStateButton18.putClientProperty("JButton.buttonType", "help"); + add(testStateButton18, "cell 1 19"); + + //---- label26 ---- + label26.setText("try me"); + add(label26, "cell 0 20"); + + //---- button2 ---- + button2.putClientProperty("JComponent.minimumWidth", 0); + button2.putClientProperty("JButton.buttonType", "help"); + add(button2, "cell 1 20"); + // JFormDesigner - End of component initialization //GEN-END:initComponents + } + + // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables + private JLabel label11; + private JLabel label5; + private JLabel label7; + private JLabel label6; + private JLabel label8; + private JLabel label1; + private FlatThemePreviewButtons.TestStateButton testStateButton1; + private FlatThemePreviewButtons.TestStateButton testStateButton7; + private FlatThemePreviewButtons.TestStateButton testStateButton4; + private FlatThemePreviewButtons.TestStateButton testStateButton10; + private JLabel label2; + private FlatThemePreviewButtons.TestStateButton testStateButton2; + private FlatThemePreviewButtons.TestStateButton testStateButton8; + private FlatThemePreviewButtons.TestStateButton testStateButton5; + private FlatThemePreviewButtons.TestStateButton testStateButton11; + private JLabel label3; + private FlatThemePreviewButtons.TestStateButton testStateButton3; + private FlatThemePreviewButtons.TestStateButton testStateButton9; + private FlatThemePreviewButtons.TestStateButton testStateButton6; + private FlatThemePreviewButtons.TestStateButton testStateButton12; + private JLabel label4; + private FlatThemePreviewButtons.TestStateButton testStateButton13; + private FlatThemePreviewButtons.TestStateButton testStateButton14; + private JLabel label10; + private JButton button1; + private FlatThemePreviewButtons.TestDefaultButton testDefaultButton1; + private JLabel label12; + private JLabel label13; + private JLabel label14; + private JLabel label15; + private JLabel label16; + private JLabel label17; + private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton1; + private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton5; + private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton9; + private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton12; + private JLabel label18; + private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton2; + private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton6; + private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton10; + private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton13; + private JLabel label19; + private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton3; + private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton7; + private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton11; + private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton14; + private JLabel label20; + private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton4; + private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton8; + private JLabel label21; + private JToggleButton toggleButton1; + private JToggleButton toggleButton2; + private JLabel label32; + private JLabel label9; + private JLabel label33; + private JLabel label22; + private FlatThemePreviewButtons.TestStateButton testStateButton15; + private FlatThemePreviewButtons.TestStateButton testStateButton19; + private JLabel label23; + private FlatThemePreviewButtons.TestStateButton testStateButton16; + private FlatThemePreviewButtons.TestStateButton testStateButton20; + private JLabel label24; + private FlatThemePreviewButtons.TestStateButton testStateButton17; + private FlatThemePreviewButtons.TestStateButton testStateButton21; + private JLabel label25; + private FlatThemePreviewButtons.TestStateButton testStateButton18; + private JLabel label26; + private JButton button2; + // JFormDesigner - End of variables declaration //GEN-END:variables + + //---- class TestStateButton ---------------------------------------------- + + private static class TestStateButton + extends JButton + { + private boolean stateHover; + private boolean statePressed; + private boolean stateFocused; + private boolean stateDefault; + + public TestStateButton() { + setModel( new DefaultButtonModel() { + @Override + public boolean isRollover() { + return isStateHover(); + } + @Override + public boolean isPressed() { + return isStatePressed(); + } + } ); + + putClientProperty( FlatClientProperties.COMPONENT_FOCUS_OWNER, + (Predicate) c -> { + return ((TestStateButton)c).isStateFocused(); + } ); + } + + public boolean isStateHover() { + return stateHover; + } + + public void setStateHover( boolean stateHover ) { + this.stateHover = stateHover; + } + + public boolean isStatePressed() { + return statePressed; + } + + public void setStatePressed( boolean statePressed ) { + this.statePressed = statePressed; + } + + public boolean isStateFocused() { + return stateFocused; + } + + public void setStateFocused( boolean stateFocused ) { + this.stateFocused = stateFocused; + } + + public boolean isStateDefault() { + return stateDefault; + } + + public void setStateDefault( boolean stateDefault ) { + this.stateDefault = stateDefault; + } + + @Override + public boolean isDefaultButton() { + return isStateDefault(); + } + } + + //---- class TestStateToggleButton ---------------------------------------- + + private static class TestStateToggleButton + extends JToggleButton + { + private boolean stateHover; + private boolean statePressed; + private boolean stateFocused; + private boolean stateSelected; + + public TestStateToggleButton() { + setModel( new DefaultButtonModel() { + @Override + public boolean isRollover() { + return isStateHover(); + } + @Override + public boolean isPressed() { + return isStatePressed(); + } + @Override + public boolean isSelected() { + return isStateSelected(); + } + } ); + + putClientProperty( FlatClientProperties.COMPONENT_FOCUS_OWNER, + (Predicate) c -> { + return ((TestStateToggleButton)c).isStateFocused(); + } ); + } + + public boolean isStateHover() { + return stateHover; + } + + public void setStateHover( boolean stateHover ) { + this.stateHover = stateHover; + } + + public boolean isStatePressed() { + return statePressed; + } + + public void setStatePressed( boolean statePressed ) { + this.statePressed = statePressed; + } + + public boolean isStateFocused() { + return stateFocused; + } + + public void setStateFocused( boolean stateFocused ) { + this.stateFocused = stateFocused; + } + + public boolean isStateSelected() { + return stateSelected; + } + + public void setStateSelected( boolean stateSelected ) { + this.stateSelected = stateSelected; + } + } + + //---- class TestDefaultButton -------------------------------------------- + + private static class TestDefaultButton + extends JButton + { + @Override + public boolean isDefaultButton() { + return true; + } + } +} diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.jfd b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.jfd new file mode 100644 index 00000000..8926f247 --- /dev/null +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.jfd @@ -0,0 +1,507 @@ +JFDML JFormDesigner: "7.0.4.0.360" Java: "16" encoding: "UTF-8" + +new FormModel { + contentType: "form/swing" + root: new FormRoot { + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "insets dialog,hidemode 3" + "$columnConstraints": "[fill][fill][fill]para[fill][fill]para" + "$rowConstraints": "[][][][][][]unrel[]para[][][][][][]unrel[]para[][][][][][]unrel[]" + } ) { + name: "this" + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label11" + "text": "JButton" + "font": &SwingDerivedFont0 new com.jformdesigner.model.SwingDerivedFont( null, 0, 4, false ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0 3 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label5" + "text": "regular" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label7" + "text": "default" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label6" + "text": "focused" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label8" + "text": "default" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label1" + "text": "none" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 2" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton1" + "text": "OK" + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 2" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton7" + "text": "OK" + "stateDefault": true + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 2" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton4" + "text": "OK" + "stateFocused": true + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 2" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton10" + "text": "OK" + "stateFocused": true + "stateDefault": true + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 2" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label2" + "text": "hover" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 3" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton2" + "text": "OK" + "stateHover": true + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 3" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton8" + "text": "OK" + "stateHover": true + "stateDefault": true + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 3" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton5" + "text": "OK" + "stateHover": true + "stateFocused": true + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 3" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton11" + "text": "OK" + "stateHover": true + "stateFocused": true + "stateDefault": true + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 3" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label3" + "text": "pressed" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 4" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton3" + "text": "OK" + "statePressed": true + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 4" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton9" + "text": "OK" + "statePressed": true + "stateDefault": true + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 4" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton6" + "text": "OK" + "statePressed": true + "stateFocused": true + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 4" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton12" + "text": "OK" + "statePressed": true + "stateFocused": true + "stateDefault": true + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 4" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label4" + "text": "disabled" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 5" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton13" + "text": "OK" + "enabled": false + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 5" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton14" + "text": "OK" + "enabled": false + "stateDefault": true + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 5" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label10" + "text": "try me" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 6" + } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "button1" + "text": "OK" + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 6" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestDefaultButton" ) { + name: "testDefaultButton1" + "text": "OK" + "$client.JComponent.minimumWidth": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 6" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label12" + "text": "JToggleButton" + "font": #SwingDerivedFont0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 7 3 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label13" + "text": "unsel." + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 8" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label14" + "text": "selected" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 8" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label15" + "text": "focused" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 8" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label16" + "text": "selected" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 8" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label17" + "text": "none" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 9" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { + name: "testStateToggleButton1" + "text": "OK" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 9" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { + name: "testStateToggleButton5" + "text": "OK" + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 9" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { + name: "testStateToggleButton9" + "text": "OK" + "stateFocused": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 9" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { + name: "testStateToggleButton12" + "text": "OK" + "stateSelected": true + "stateFocused": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 9" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label18" + "text": "hover" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 10" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { + name: "testStateToggleButton2" + "text": "OK" + "stateHover": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 10" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { + name: "testStateToggleButton6" + "text": "OK" + "stateHover": true + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 10" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { + name: "testStateToggleButton10" + "text": "OK" + "stateHover": true + "stateFocused": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 10" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { + name: "testStateToggleButton13" + "text": "OK" + "stateHover": true + "stateSelected": true + "stateFocused": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 10" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label19" + "text": "pressed" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 11" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { + name: "testStateToggleButton3" + "text": "OK" + "statePressed": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 11" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { + name: "testStateToggleButton7" + "text": "OK" + "statePressed": true + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 11" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { + name: "testStateToggleButton11" + "text": "OK" + "statePressed": true + "stateFocused": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 11" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { + name: "testStateToggleButton14" + "text": "OK" + "statePressed": true + "stateSelected": true + "stateFocused": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 11" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label20" + "text": "disabled" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 12" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { + name: "testStateToggleButton4" + "text": "OK" + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 12" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { + name: "testStateToggleButton8" + "text": "OK" + "enabled": false + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 12" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label21" + "text": "try me" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 13" + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "toggleButton1" + "text": "OK" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 13" + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "toggleButton2" + "text": "OK" + "selected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 13" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label32" + "text": "Help Button" + "font": #SwingDerivedFont0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 14 2 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label9" + "text": "regular" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 15" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label33" + "text": "focused" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 15" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label22" + "text": "none" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 16" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton15" + "$client.JComponent.minimumWidth": 0 + "$client.JButton.buttonType": "help" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 16" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton19" + "stateFocused": true + "$client.JComponent.minimumWidth": 0 + "$client.JButton.buttonType": "help" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 16" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label23" + "text": "hover" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 17" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton16" + "stateHover": true + "$client.JComponent.minimumWidth": 0 + "$client.JButton.buttonType": "help" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 17" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton20" + "stateHover": true + "stateFocused": true + "$client.JComponent.minimumWidth": 0 + "$client.JButton.buttonType": "help" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 17" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label24" + "text": "pressed" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 18" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton17" + "statePressed": true + "$client.JComponent.minimumWidth": 0 + "$client.JButton.buttonType": "help" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 18" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton21" + "statePressed": true + "stateFocused": true + "$client.JComponent.minimumWidth": 0 + "$client.JButton.buttonType": "help" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 18" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label25" + "text": "disabled" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 19" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { + name: "testStateButton18" + "enabled": false + "$client.JComponent.minimumWidth": 0 + "$client.JButton.buttonType": "help" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 19" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label26" + "text": "try me" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 20" + } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "button2" + "$client.JComponent.minimumWidth": 0 + "$client.JButton.buttonType": "help" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 20" + } ) + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 0 ) + "size": new java.awt.Dimension( 335, 685 ) + } ) + } +} diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.java new file mode 100644 index 00000000..4d30fac8 --- /dev/null +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.java @@ -0,0 +1,558 @@ +/* + * Copyright 2021 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.themeeditor; + +import java.util.function.Predicate; +import javax.swing.*; +import com.formdev.flatlaf.FlatClientProperties; +import net.miginfocom.swing.*; + +/** + * @author Karl Tauber + */ +class FlatThemePreviewSwitches + extends JPanel +{ + FlatThemePreviewSwitches() { + initComponents(); + } + + private void initComponents() { + // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents + label22 = new JLabel(); + label23 = new JLabel(); + label28 = new JLabel(); + label24 = new JLabel(); + label29 = new JLabel(); + label17 = new JLabel(); + testStateCheckBox1 = new FlatThemePreviewSwitches.TestStateCheckBox(); + testStateCheckBox8 = new FlatThemePreviewSwitches.TestStateCheckBox(); + testStateCheckBox5 = new FlatThemePreviewSwitches.TestStateCheckBox(); + testStateCheckBox12 = new FlatThemePreviewSwitches.TestStateCheckBox(); + label18 = new JLabel(); + testStateCheckBox2 = new FlatThemePreviewSwitches.TestStateCheckBox(); + testStateCheckBox9 = new FlatThemePreviewSwitches.TestStateCheckBox(); + testStateCheckBox6 = new FlatThemePreviewSwitches.TestStateCheckBox(); + testStateCheckBox13 = new FlatThemePreviewSwitches.TestStateCheckBox(); + label19 = new JLabel(); + testStateCheckBox3 = new FlatThemePreviewSwitches.TestStateCheckBox(); + testStateCheckBox10 = new FlatThemePreviewSwitches.TestStateCheckBox(); + testStateCheckBox7 = new FlatThemePreviewSwitches.TestStateCheckBox(); + testStateCheckBox14 = new FlatThemePreviewSwitches.TestStateCheckBox(); + label20 = new JLabel(); + testStateCheckBox4 = new FlatThemePreviewSwitches.TestStateCheckBox(); + testStateCheckBox11 = new FlatThemePreviewSwitches.TestStateCheckBox(); + label21 = new JLabel(); + checkBox1 = new JCheckBox(); + checkBox2 = new JCheckBox(); + label27 = new JLabel(); + label25 = new JLabel(); + label30 = new JLabel(); + label26 = new JLabel(); + label31 = new JLabel(); + label36 = new JLabel(); + testStateRadioButton1 = new FlatThemePreviewSwitches.TestStateRadioButton(); + testStateRadioButton8 = new FlatThemePreviewSwitches.TestStateRadioButton(); + testStateRadioButton5 = new FlatThemePreviewSwitches.TestStateRadioButton(); + testStateRadioButton9 = new FlatThemePreviewSwitches.TestStateRadioButton(); + label35 = new JLabel(); + testStateRadioButton2 = new FlatThemePreviewSwitches.TestStateRadioButton(); + testStateRadioButton10 = new FlatThemePreviewSwitches.TestStateRadioButton(); + testStateRadioButton6 = new FlatThemePreviewSwitches.TestStateRadioButton(); + testStateRadioButton11 = new FlatThemePreviewSwitches.TestStateRadioButton(); + label34 = new JLabel(); + testStateRadioButton3 = new FlatThemePreviewSwitches.TestStateRadioButton(); + testStateRadioButton12 = new FlatThemePreviewSwitches.TestStateRadioButton(); + testStateRadioButton7 = new FlatThemePreviewSwitches.TestStateRadioButton(); + testStateRadioButton13 = new FlatThemePreviewSwitches.TestStateRadioButton(); + label33 = new JLabel(); + testStateRadioButton4 = new FlatThemePreviewSwitches.TestStateRadioButton(); + testStateRadioButton14 = new FlatThemePreviewSwitches.TestStateRadioButton(); + label32 = new JLabel(); + radioButton1 = new JRadioButton(); + radioButton2 = new JRadioButton(); + + //======== this ======== + setLayout(new MigLayout( + "insets dialog,hidemode 3", + // columns + "[fill]" + + "[fill]" + + "[fill]para" + + "[fill]" + + "[fill]para", + // rows + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]unrel" + + "[]para" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]unrel" + + "[]")); + + //---- label22 ---- + label22.setText("JCheckBox"); + label22.setFont(label22.getFont().deriveFont(label22.getFont().getSize() + 4f)); + add(label22, "cell 0 0 3 1"); + + //---- label23 ---- + label23.setText("unsel."); + add(label23, "cell 1 1"); + + //---- label28 ---- + label28.setText("selected"); + add(label28, "cell 2 1"); + + //---- label24 ---- + label24.setText("focused"); + add(label24, "cell 3 1"); + + //---- label29 ---- + label29.setText("selected"); + add(label29, "cell 4 1"); + + //---- label17 ---- + label17.setText("none"); + add(label17, "cell 0 2"); + + //---- testStateCheckBox1 ---- + testStateCheckBox1.setText("text"); + add(testStateCheckBox1, "cell 1 2"); + + //---- testStateCheckBox8 ---- + testStateCheckBox8.setText("text"); + testStateCheckBox8.setStateSelected(true); + add(testStateCheckBox8, "cell 2 2"); + + //---- testStateCheckBox5 ---- + testStateCheckBox5.setText("text"); + testStateCheckBox5.setStateFocused(true); + add(testStateCheckBox5, "cell 3 2"); + + //---- testStateCheckBox12 ---- + testStateCheckBox12.setText("text"); + testStateCheckBox12.setStateFocused(true); + testStateCheckBox12.setStateSelected(true); + add(testStateCheckBox12, "cell 4 2"); + + //---- label18 ---- + label18.setText("hover"); + add(label18, "cell 0 3"); + + //---- testStateCheckBox2 ---- + testStateCheckBox2.setText("text"); + testStateCheckBox2.setStateHover(true); + add(testStateCheckBox2, "cell 1 3"); + + //---- testStateCheckBox9 ---- + testStateCheckBox9.setText("text"); + testStateCheckBox9.setStateHover(true); + testStateCheckBox9.setStateSelected(true); + add(testStateCheckBox9, "cell 2 3"); + + //---- testStateCheckBox6 ---- + testStateCheckBox6.setText("text"); + testStateCheckBox6.setStateFocused(true); + testStateCheckBox6.setStateHover(true); + add(testStateCheckBox6, "cell 3 3"); + + //---- testStateCheckBox13 ---- + testStateCheckBox13.setText("text"); + testStateCheckBox13.setStateFocused(true); + testStateCheckBox13.setStateHover(true); + testStateCheckBox13.setStateSelected(true); + add(testStateCheckBox13, "cell 4 3"); + + //---- label19 ---- + label19.setText("pressed"); + add(label19, "cell 0 4"); + + //---- testStateCheckBox3 ---- + testStateCheckBox3.setText("text"); + testStateCheckBox3.setStatePressed(true); + add(testStateCheckBox3, "cell 1 4"); + + //---- testStateCheckBox10 ---- + testStateCheckBox10.setText("text"); + testStateCheckBox10.setStatePressed(true); + testStateCheckBox10.setStateSelected(true); + add(testStateCheckBox10, "cell 2 4"); + + //---- testStateCheckBox7 ---- + testStateCheckBox7.setText("text"); + testStateCheckBox7.setStateFocused(true); + testStateCheckBox7.setStatePressed(true); + add(testStateCheckBox7, "cell 3 4"); + + //---- testStateCheckBox14 ---- + testStateCheckBox14.setText("text"); + testStateCheckBox14.setStateFocused(true); + testStateCheckBox14.setStatePressed(true); + testStateCheckBox14.setStateSelected(true); + add(testStateCheckBox14, "cell 4 4"); + + //---- label20 ---- + label20.setText("disabled"); + add(label20, "cell 0 5"); + + //---- testStateCheckBox4 ---- + testStateCheckBox4.setText("text"); + testStateCheckBox4.setEnabled(false); + add(testStateCheckBox4, "cell 1 5"); + + //---- testStateCheckBox11 ---- + testStateCheckBox11.setText("text"); + testStateCheckBox11.setEnabled(false); + testStateCheckBox11.setStateSelected(true); + add(testStateCheckBox11, "cell 2 5"); + + //---- label21 ---- + label21.setText("try me"); + add(label21, "cell 0 6"); + + //---- checkBox1 ---- + checkBox1.setText("text"); + add(checkBox1, "cell 1 6"); + + //---- checkBox2 ---- + checkBox2.setText("text"); + checkBox2.setSelected(true); + add(checkBox2, "cell 2 6"); + + //---- label27 ---- + label27.setText("JRadioButton"); + label27.setFont(label27.getFont().deriveFont(label27.getFont().getSize() + 4f)); + add(label27, "cell 0 7 3 1"); + + //---- label25 ---- + label25.setText("unsel."); + add(label25, "cell 1 8"); + + //---- label30 ---- + label30.setText("selected"); + add(label30, "cell 2 8"); + + //---- label26 ---- + label26.setText("focused"); + add(label26, "cell 3 8"); + + //---- label31 ---- + label31.setText("selected"); + add(label31, "cell 4 8"); + + //---- label36 ---- + label36.setText("none"); + add(label36, "cell 0 9"); + + //---- testStateRadioButton1 ---- + testStateRadioButton1.setText("text"); + add(testStateRadioButton1, "cell 1 9"); + + //---- testStateRadioButton8 ---- + testStateRadioButton8.setText("text"); + testStateRadioButton8.setStateSelected(true); + add(testStateRadioButton8, "cell 2 9"); + + //---- testStateRadioButton5 ---- + testStateRadioButton5.setText("text"); + testStateRadioButton5.setStateFocused(true); + add(testStateRadioButton5, "cell 3 9"); + + //---- testStateRadioButton9 ---- + testStateRadioButton9.setText("text"); + testStateRadioButton9.setStateFocused(true); + testStateRadioButton9.setStateSelected(true); + add(testStateRadioButton9, "cell 4 9"); + + //---- label35 ---- + label35.setText("hover"); + add(label35, "cell 0 10"); + + //---- testStateRadioButton2 ---- + testStateRadioButton2.setText("text"); + testStateRadioButton2.setStateHover(true); + add(testStateRadioButton2, "cell 1 10"); + + //---- testStateRadioButton10 ---- + testStateRadioButton10.setText("text"); + testStateRadioButton10.setStateHover(true); + testStateRadioButton10.setStateSelected(true); + add(testStateRadioButton10, "cell 2 10"); + + //---- testStateRadioButton6 ---- + testStateRadioButton6.setText("text"); + testStateRadioButton6.setStateFocused(true); + testStateRadioButton6.setStateHover(true); + add(testStateRadioButton6, "cell 3 10"); + + //---- testStateRadioButton11 ---- + testStateRadioButton11.setText("text"); + testStateRadioButton11.setStateFocused(true); + testStateRadioButton11.setStateHover(true); + testStateRadioButton11.setStateSelected(true); + add(testStateRadioButton11, "cell 4 10"); + + //---- label34 ---- + label34.setText("pressed"); + add(label34, "cell 0 11"); + + //---- testStateRadioButton3 ---- + testStateRadioButton3.setText("text"); + testStateRadioButton3.setStatePressed(true); + add(testStateRadioButton3, "cell 1 11"); + + //---- testStateRadioButton12 ---- + testStateRadioButton12.setText("text"); + testStateRadioButton12.setStatePressed(true); + testStateRadioButton12.setStateSelected(true); + add(testStateRadioButton12, "cell 2 11"); + + //---- testStateRadioButton7 ---- + testStateRadioButton7.setText("text"); + testStateRadioButton7.setStateFocused(true); + testStateRadioButton7.setStatePressed(true); + add(testStateRadioButton7, "cell 3 11"); + + //---- testStateRadioButton13 ---- + testStateRadioButton13.setText("text"); + testStateRadioButton13.setStateFocused(true); + testStateRadioButton13.setStatePressed(true); + testStateRadioButton13.setStateSelected(true); + add(testStateRadioButton13, "cell 4 11"); + + //---- label33 ---- + label33.setText("disabled"); + add(label33, "cell 0 12"); + + //---- testStateRadioButton4 ---- + testStateRadioButton4.setText("text"); + testStateRadioButton4.setEnabled(false); + add(testStateRadioButton4, "cell 1 12"); + + //---- testStateRadioButton14 ---- + testStateRadioButton14.setText("text"); + testStateRadioButton14.setEnabled(false); + testStateRadioButton14.setStateSelected(true); + add(testStateRadioButton14, "cell 2 12"); + + //---- label32 ---- + label32.setText("try me"); + add(label32, "cell 0 13"); + + //---- radioButton1 ---- + radioButton1.setText("text"); + add(radioButton1, "cell 1 13"); + + //---- radioButton2 ---- + radioButton2.setText("text"); + radioButton2.setSelected(true); + add(radioButton2, "cell 2 13"); + // JFormDesigner - End of component initialization //GEN-END:initComponents + } + + // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables + private JLabel label22; + private JLabel label23; + private JLabel label28; + private JLabel label24; + private JLabel label29; + private JLabel label17; + private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox1; + private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox8; + private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox5; + private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox12; + private JLabel label18; + private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox2; + private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox9; + private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox6; + private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox13; + private JLabel label19; + private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox3; + private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox10; + private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox7; + private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox14; + private JLabel label20; + private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox4; + private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox11; + private JLabel label21; + private JCheckBox checkBox1; + private JCheckBox checkBox2; + private JLabel label27; + private JLabel label25; + private JLabel label30; + private JLabel label26; + private JLabel label31; + private JLabel label36; + private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton1; + private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton8; + private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton5; + private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton9; + private JLabel label35; + private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton2; + private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton10; + private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton6; + private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton11; + private JLabel label34; + private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton3; + private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton12; + private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton7; + private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton13; + private JLabel label33; + private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton4; + private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton14; + private JLabel label32; + private JRadioButton radioButton1; + private JRadioButton radioButton2; + // JFormDesigner - End of variables declaration //GEN-END:variables + + //---- class TestStateCheckBox -------------------------------------------- + + private static class TestStateCheckBox + extends JCheckBox + { + private boolean stateHover; + private boolean statePressed; + private boolean stateFocused; + private boolean stateSelected; + + public TestStateCheckBox() { + setModel( new DefaultButtonModel() { + @Override + public boolean isRollover() { + return isStateHover(); + } + @Override + public boolean isPressed() { + return isStatePressed(); + } + @Override + public boolean isSelected() { + return isStateSelected(); + } + } ); + + putClientProperty( FlatClientProperties.COMPONENT_FOCUS_OWNER, + (Predicate) c -> { + return ((TestStateCheckBox)c).isStateFocused(); + } ); + } + + public boolean isStateHover() { + return stateHover; + } + + public void setStateHover( boolean stateHover ) { + this.stateHover = stateHover; + } + + public boolean isStatePressed() { + return statePressed; + } + + public void setStatePressed( boolean statePressed ) { + this.statePressed = statePressed; + } + + public boolean isStateFocused() { + return stateFocused; + } + + public void setStateFocused( boolean stateFocused ) { + this.stateFocused = stateFocused; + } + + public boolean isStateSelected() { + return stateSelected; + } + + public void setStateSelected( boolean stateSelected ) { + this.stateSelected = stateSelected; + } + } + + //---- class TestStateRadioButton ----------------------------------------- + + private static class TestStateRadioButton + extends JRadioButton + { + private boolean stateHover; + private boolean statePressed; + private boolean stateFocused; + private boolean stateSelected; + + public TestStateRadioButton() { + setModel( new DefaultButtonModel() { + @Override + public boolean isRollover() { + return isStateHover(); + } + @Override + public boolean isPressed() { + return isStatePressed(); + } + @Override + public boolean isSelected() { + return isStateSelected(); + } + } ); + + putClientProperty( FlatClientProperties.COMPONENT_FOCUS_OWNER, + (Predicate) c -> { + return ((TestStateRadioButton)c).isStateFocused(); + } ); + } + + public boolean isStateHover() { + return stateHover; + } + + public void setStateHover( boolean stateHover ) { + this.stateHover = stateHover; + } + + public boolean isStatePressed() { + return statePressed; + } + + public void setStatePressed( boolean statePressed ) { + this.statePressed = statePressed; + } + + public boolean isStateFocused() { + return stateFocused; + } + + public void setStateFocused( boolean stateFocused ) { + this.stateFocused = stateFocused; + } + + public boolean isStateSelected() { + return stateSelected; + } + + public void setStateSelected( boolean stateSelected ) { + this.stateSelected = stateSelected; + } + } +} diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.jfd b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.jfd new file mode 100644 index 00000000..819e9be7 --- /dev/null +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.jfd @@ -0,0 +1,379 @@ +JFDML JFormDesigner: "7.0.4.0.360" Java: "16" encoding: "UTF-8" + +new FormModel { + contentType: "form/swing" + root: new FormRoot { + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "insets dialog,hidemode 3" + "$columnConstraints": "[fill][fill][fill]para[fill][fill]para" + "$rowConstraints": "[][][][][][]unrel[]para[][][][][][]unrel[]" + } ) { + name: "this" + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label22" + "text": "JCheckBox" + "font": &SwingDerivedFont0 new com.jformdesigner.model.SwingDerivedFont( null, 0, 4, false ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0 3 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label23" + "text": "unsel." + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label28" + "text": "selected" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label24" + "text": "focused" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label29" + "text": "selected" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label17" + "text": "none" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 2" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { + name: "testStateCheckBox1" + "text": "text" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 2" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { + name: "testStateCheckBox8" + "text": "text" + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 2" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { + name: "testStateCheckBox5" + "text": "text" + "stateFocused": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 2" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { + name: "testStateCheckBox12" + "text": "text" + "stateFocused": true + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 2" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label18" + "text": "hover" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 3" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { + name: "testStateCheckBox2" + "text": "text" + "stateHover": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 3" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { + name: "testStateCheckBox9" + "text": "text" + "stateHover": true + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 3" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { + name: "testStateCheckBox6" + "text": "text" + "stateFocused": true + "stateHover": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 3" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { + name: "testStateCheckBox13" + "text": "text" + "stateFocused": true + "stateHover": true + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 3" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label19" + "text": "pressed" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 4" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { + name: "testStateCheckBox3" + "text": "text" + "statePressed": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 4" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { + name: "testStateCheckBox10" + "text": "text" + "statePressed": true + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 4" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { + name: "testStateCheckBox7" + "text": "text" + "stateFocused": true + "statePressed": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 4" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { + name: "testStateCheckBox14" + "text": "text" + "stateFocused": true + "statePressed": true + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 4" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label20" + "text": "disabled" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 5" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { + name: "testStateCheckBox4" + "text": "text" + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 5" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { + name: "testStateCheckBox11" + "text": "text" + "enabled": false + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 5" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label21" + "text": "try me" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 6" + } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "checkBox1" + "text": "text" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 6" + } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "checkBox2" + "text": "text" + "selected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 6" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label27" + "text": "JRadioButton" + "font": #SwingDerivedFont0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 7 3 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label25" + "text": "unsel." + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 8" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label30" + "text": "selected" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 8" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label26" + "text": "focused" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 8" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label31" + "text": "selected" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 8" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label36" + "text": "none" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 9" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { + name: "testStateRadioButton1" + "text": "text" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 9" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { + name: "testStateRadioButton8" + "text": "text" + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 9" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { + name: "testStateRadioButton5" + "text": "text" + "stateFocused": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 9" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { + name: "testStateRadioButton9" + "text": "text" + "stateFocused": true + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 9" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label35" + "text": "hover" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 10" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { + name: "testStateRadioButton2" + "text": "text" + "stateHover": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 10" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { + name: "testStateRadioButton10" + "text": "text" + "stateHover": true + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 10" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { + name: "testStateRadioButton6" + "text": "text" + "stateFocused": true + "stateHover": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 10" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { + name: "testStateRadioButton11" + "text": "text" + "stateFocused": true + "stateHover": true + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 10" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label34" + "text": "pressed" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 11" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { + name: "testStateRadioButton3" + "text": "text" + "statePressed": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 11" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { + name: "testStateRadioButton12" + "text": "text" + "statePressed": true + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 11" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { + name: "testStateRadioButton7" + "text": "text" + "stateFocused": true + "statePressed": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 11" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { + name: "testStateRadioButton13" + "text": "text" + "stateFocused": true + "statePressed": true + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 11" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label33" + "text": "disabled" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 12" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { + name: "testStateRadioButton4" + "text": "text" + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 12" + } ) + add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { + name: "testStateRadioButton14" + "text": "text" + "enabled": false + "stateSelected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 12" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label32" + "text": "try me" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 13" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "radioButton1" + "text": "text" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 13" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "radioButton2" + "text": "text" + "selected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 13" + } ) + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 0 ) + "size": new java.awt.Dimension( 325, 685 ) + } ) + } +} From c2c79c467613a4fc17d4f86f533af0818e81a3ff Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 5 Sep 2021 11:13:29 +0200 Subject: [PATCH 09/13] Theme Editor: - remember last used preview tab - sync selected preview tab with all editors --- .../flatlaf/themeeditor/FlatThemePreview.java | 21 ++++++++++++++++++- .../flatlaf/themeeditor/FlatThemePreview.jfd | 1 - 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.java index 102b798e..f8239751 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.java @@ -21,6 +21,7 @@ import java.awt.*; import java.awt.event.HierarchyEvent; import java.util.Map; import java.util.WeakHashMap; +import java.util.prefs.Preferences; import javax.swing.*; import javax.swing.UIDefaults.ActiveValue; import javax.swing.UIDefaults.LazyValue; @@ -36,20 +37,27 @@ class FlatThemePreview extends JPanel implements DocumentListener { + private static final String KEY_SELECTED_TAB = "preview.selectedTab"; + private final FlatSyntaxTextArea textArea; private final Timer timer; + private final Preferences state; private final Map lazyValueCache = new WeakHashMap<>(); private int runWithUIDefaultsGetterLevel; FlatThemePreview( FlatSyntaxTextArea textArea ) { this.textArea = textArea; + state = Preferences.userRoot().node( FlatThemeFileEditor.PREFS_ROOT_PATH ); initComponents(); + // add tabs tabbedPane.addTab( "All", createPreviewTab( new FlatThemePreviewAll( this ) ) ); tabbedPane.addTab( "Buttons", createPreviewTab( new FlatThemePreviewButtons() ) ); tabbedPane.addTab( "Switches", createPreviewTab( new FlatThemePreviewSwitches() ) ); + selectRecentTab(); + tabbedPane.addChangeListener( e -> selectedTabChanged() ); // timer used for delayed preview updates timer = new Timer( 300, e -> update() ); @@ -61,6 +69,7 @@ class FlatThemePreview // update when showing preview (e.g. activating tab) addHierarchyListener( e -> { if( (e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 && isShowing() ) + selectRecentTab(); updateLater(); } ); } @@ -74,6 +83,17 @@ class FlatThemePreview return scrollPane; } + private void selectRecentTab() { + int selectedTab = state.getInt( KEY_SELECTED_TAB, -1 ); + if( selectedTab >= 0 && selectedTab < tabbedPane.getTabCount() ) + tabbedPane.setSelectedIndex( selectedTab ); + } + + private void selectedTabChanged() { + update(); + state.putInt( KEY_SELECTED_TAB, tabbedPane.getSelectedIndex() ); + } + @Override public void insertUpdate( DocumentEvent e ) { timer.restart(); @@ -169,7 +189,6 @@ class FlatThemePreview { tabbedPane.setLeadingComponent(previewLabel); tabbedPane.setTabAreaAlignment(FlatTabbedPane.TabAreaAlignment.trailing); - tabbedPane.addChangeListener(e -> update()); } add(tabbedPane, BorderLayout.CENTER); diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.jfd b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.jfd index 7d1e80a7..3aaca34f 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.jfd +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.jfd @@ -9,7 +9,6 @@ new FormModel { name: "tabbedPane" "leadingComponent": new FormReference( "previewLabel" ) "tabAreaAlignment": enum com.formdev.flatlaf.extras.components.FlatTabbedPane$TabAreaAlignment trailing - addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "update", false ) ) }, new FormLayoutConstraints( class java.lang.String ) { "value": "Center" } ) From 824db2e3bdb586dfea959d5e6101616ce9a918b3 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 5 Sep 2021 11:51:28 +0200 Subject: [PATCH 10/13] Table and TableHeader: added UI defaults to show last vertical line (issue #332) --- .../java/com/formdev/flatlaf/ui/FlatTableHeaderBorder.java | 4 ++++ .../main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java | 1 + .../src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java | 6 ++++++ .../main/resources/com/formdev/flatlaf/FlatLaf.properties | 3 ++- flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0_202.txt | 2 ++ flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0_202.txt | 2 ++ flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0_202.txt | 2 ++ .../com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt | 2 ++ 8 files changed, 21 insertions(+), 1 deletion(-) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderBorder.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderBorder.java index d8e6e87c..836aaac6 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderBorder.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderBorder.java @@ -44,6 +44,7 @@ public class FlatTableHeaderBorder { protected Color separatorColor = UIManager.getColor( "TableHeader.separatorColor" ); protected Color bottomSeparatorColor = UIManager.getColor( "TableHeader.bottomSeparatorColor" ); + protected boolean showLastVerticalLine = UIManager.getBoolean( "TableHeader.showLastVerticalLine" ); public FlatTableHeaderBorder() { super( UIManager.getInsets( "TableHeader.cellMargins" ) ); @@ -108,6 +109,9 @@ public class FlatTableHeaderBorder } protected boolean hideTrailingVerticalLine( JTableHeader header ) { + if( showLastVerticalLine ) + return false; + Container viewport = header.getParent(); Container viewportParent = (viewport != null) ? viewport.getParent() : null; if( !(viewportParent instanceof JScrollPane) ) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java index 82d861ad..bbf1ee7b 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java @@ -62,6 +62,7 @@ import com.formdev.flatlaf.util.UIScale; * @uiDefault TableHeader.cellMargins Insets * @uiDefault TableHeader.separatorColor Color * @uiDefault TableHeader.bottomSeparatorColor Color + * @uiDefault TableHeader.showLastVerticalLine boolean * * @author Karl Tauber */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java index 11ad7154..15aafe1a 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java @@ -69,6 +69,7 @@ import com.formdev.flatlaf.util.UIScale; * @uiDefault Table.rowHeight int * @uiDefault Table.showHorizontalLines boolean * @uiDefault Table.showVerticalLines boolean + * @uiDefault Table.showLastVerticalLine boolean * @uiDefault Table.intercellSpacing Dimension * @uiDefault Table.selectionInactiveBackground Color * @uiDefault Table.selectionInactiveForeground Color @@ -90,6 +91,7 @@ public class FlatTableUI { protected boolean showHorizontalLines; protected boolean showVerticalLines; + protected boolean showLastVerticalLine; protected Dimension intercellSpacing; protected Color selectionBackground; @@ -111,6 +113,7 @@ public class FlatTableUI showHorizontalLines = UIManager.getBoolean( "Table.showHorizontalLines" ); showVerticalLines = UIManager.getBoolean( "Table.showVerticalLines" ); + showLastVerticalLine = UIManager.getBoolean( "Table.showLastVerticalLine" ); intercellSpacing = UIManager.getDimension( "Table.intercellSpacing" ); selectionBackground = UIManager.getColor( "Table.selectionBackground" ); @@ -292,6 +295,9 @@ public class FlatTableUI } protected boolean hideLastVerticalLine() { + if( showLastVerticalLine ) + return false; + Container viewport = SwingUtilities.getUnwrappedParent( table ); Container viewportParent = (viewport != null) ? viewport.getParent() : null; if( !(viewportParent instanceof JScrollPane) ) diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties index 5688074e..77b28abc 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -628,6 +628,7 @@ TabbedPane.closeCrossLineWidth = {float}1 Table.rowHeight = 20 Table.showHorizontalLines = false Table.showVerticalLines = false +Table.showLastVerticalLine = false Table.consistentHomeEndKeyBehavior = true Table.intercellSpacing = {dimension}0,0 Table.scrollPaneBorder = com.formdev.flatlaf.ui.FlatBorder @@ -657,7 +658,7 @@ TableHeader.cellBorder = com.formdev.flatlaf.ui.FlatTableHeaderBorder TableHeader.cellMargins = 2,3,2,3 TableHeader.focusCellBackground = $TableHeader.background TableHeader.background = @textComponentBackground - +TableHeader.showLastVerticalLine = false #---- TextArea ---- diff --git a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0_202.txt b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0_202.txt index 2f401fdc..7078e1ca 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0_202.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0_202.txt @@ -1078,6 +1078,7 @@ Table.selectionForeground #bbbbbb HSL 0 0 73 javax.swing.plaf.Colo Table.selectionInactiveBackground #0d293e HSL 206 65 15 javax.swing.plaf.ColorUIResource [UI] Table.selectionInactiveForeground #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI] Table.showHorizontalLines false +Table.showLastVerticalLine false Table.showVerticalLines false Table.sortIconColor #adadad HSL 0 0 68 javax.swing.plaf.ColorUIResource [UI] @@ -1093,6 +1094,7 @@ TableHeader.font [active] $defaultFont [UI] TableHeader.foreground #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI] TableHeader.height 25 TableHeader.separatorColor #5e6364 HSL 190 3 38 javax.swing.plaf.ColorUIResource [UI] +TableHeader.showLastVerticalLine false TableHeaderUI com.formdev.flatlaf.ui.FlatTableHeaderUI diff --git a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0_202.txt b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0_202.txt index d3942343..722b34f6 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0_202.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0_202.txt @@ -1083,6 +1083,7 @@ Table.selectionForeground #ffffff HSL 0 0 100 javax.swing.plaf.Colo Table.selectionInactiveBackground #d4d4d4 HSL 0 0 83 javax.swing.plaf.ColorUIResource [UI] Table.selectionInactiveForeground #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] Table.showHorizontalLines false +Table.showLastVerticalLine false Table.showVerticalLines false Table.sortIconColor #afafaf HSL 0 0 69 javax.swing.plaf.ColorUIResource [UI] @@ -1098,6 +1099,7 @@ TableHeader.font [active] $defaultFont [UI] TableHeader.foreground #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] TableHeader.height 25 TableHeader.separatorColor #e6e6e6 HSL 0 0 90 javax.swing.plaf.ColorUIResource [UI] +TableHeader.showLastVerticalLine false TableHeaderUI com.formdev.flatlaf.ui.FlatTableHeaderUI diff --git a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0_202.txt b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0_202.txt index 40d64308..394f5678 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0_202.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0_202.txt @@ -1088,6 +1088,7 @@ Table.selectionForeground #ffff00 HSL 60 100 50 javax.swing.plaf.Colo Table.selectionInactiveBackground #888888 HSL 0 0 53 javax.swing.plaf.ColorUIResource [UI] Table.selectionInactiveForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] Table.showHorizontalLines false +Table.showLastVerticalLine false Table.showVerticalLines false Table.sortIconColor #ffff00 HSL 60 100 50 javax.swing.plaf.ColorUIResource [UI] @@ -1103,6 +1104,7 @@ TableHeader.font [active] $defaultFont [UI] TableHeader.foreground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] TableHeader.height 25 TableHeader.separatorColor #00ff00 HSL 120 100 50 javax.swing.plaf.ColorUIResource [UI] +TableHeader.showLastVerticalLine false TableHeaderUI com.formdev.flatlaf.ui.FlatTableHeaderUI diff --git a/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt b/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt index c50e3328..fd85f54b 100644 --- a/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt +++ b/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt @@ -830,6 +830,7 @@ Table.selectionForeground Table.selectionInactiveBackground Table.selectionInactiveForeground Table.showHorizontalLines +Table.showLastVerticalLine Table.showVerticalLines Table.sortIconColor TableHeader.ancestorInputMap @@ -842,6 +843,7 @@ TableHeader.font TableHeader.foreground TableHeader.height TableHeader.separatorColor +TableHeader.showLastVerticalLine TableHeaderUI TableUI TaskPane.background From 8640dee05383a96613b96e2cd9fa9d9ab56d33d0 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 5 Sep 2021 21:08:36 +0200 Subject: [PATCH 11/13] Theme Editor: preview improvements: - added "focused" checkbox to "All" tab to preview focused components - added "button type" selector to "Buttons" tab - added "unfocused"/"focused" header labels to "Buttons" and "Switches" tabs - use local variables instead of fields where possible --- .../themeeditor/FlatThemePreviewAll.java | 262 ++++----- .../themeeditor/FlatThemePreviewAll.jfd | 49 ++ .../themeeditor/FlatThemePreviewButtons.java | 495 ++++++++++-------- .../themeeditor/FlatThemePreviewButtons.jfd | 282 +++++++--- .../themeeditor/FlatThemePreviewSwitches.java | 292 +++++------ .../themeeditor/FlatThemePreviewSwitches.jfd | 143 +++-- 6 files changed, 881 insertions(+), 642 deletions(-) diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java index 1ab0dcde..4f651072 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java @@ -21,11 +21,13 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.beans.PropertyVetoException; import java.util.function.Function; +import java.util.function.Predicate; import javax.swing.*; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableRowSorter; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; +import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.extras.components.*; import com.formdev.flatlaf.ui.FlatTabbedPaneUI; @@ -77,13 +79,20 @@ class FlatThemePreviewAll } private void enabledChanged() { + boolean enabled = enabledCheckBox.isSelected(); + + // disable "focused" checkbox because disabled components are not focusable + focusedCheckBox.setEnabled( enabled ); + if( focusedCheckBox.isSelected() ) + focusedChanged(); + preview.runWithUIDefaultsGetter( () -> { - enableDisable( this, enabledCheckBox.isSelected() ); + enableDisable( this, enabled ); } ); } private void enableDisable( Component comp, boolean enabled ) { - if( comp != enabledCheckBox && comp != menu2 ) + if( comp != enabledCheckBox && comp != focusedCheckBox && comp != menu2 ) comp.setEnabled( enabled ); if( !(comp instanceof Container) || comp instanceof JInternalFrame ) @@ -110,6 +119,29 @@ class FlatThemePreviewAll } } + private void focusedChanged() { + Predicate value = focusedCheckBox.isSelected() && enabledCheckBox.isSelected() + ? value = c -> true + : null; + focusComponent( this, value ); + repaint(); + } + + private void focusComponent( Component comp, Object value ) { + if( comp != enabledCheckBox && comp != focusedCheckBox && comp != menu2 && comp instanceof JComponent ) + ((JComponent)comp).putClientProperty( FlatClientProperties.COMPONENT_FOCUS_OWNER, value ); + + if( !(comp instanceof Container) || comp instanceof JInternalFrame ) + return; + + for( Component c : ((Container)comp).getComponents() ) { + if( c instanceof JScrollPane ) + c = ((JScrollPane)c).getViewport().getView(); + + focusComponent( c, value ); + } + } + private void changeProgress() { int value = slider3.getValue(); progressBar1.setValue( value ); @@ -134,90 +166,91 @@ class FlatThemePreviewAll private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents enabledCheckBox = new JCheckBox(); - labelLabel = new JLabel(); - label1 = new JLabel(); - flatButton1 = new FlatButton(); - buttonLabel = new JLabel(); - button1 = new JButton(); - testDefaultButton1 = new FlatThemePreviewAll.PreviewDefaultButton(); - helpButton = new FlatButton(); - hSpacer2 = new JPanel(null); - toggleButtonLabel = new JLabel(); - toggleButton1 = new JToggleButton(); - toggleButton3 = new JToggleButton(); - hSpacer1 = new JPanel(null); - checkBoxLabel = new JLabel(); - checkBox1 = new JCheckBox(); - checkBox3 = new JCheckBox(); - hSpacer3 = new JPanel(null); - radioButtonLabel = new JLabel(); - radioButton1 = new JRadioButton(); - radioButton3 = new JRadioButton(); - hSpacer4 = new JPanel(null); - comboBoxLabel = new JLabel(); - comboBox1 = new FlatComboBox<>(); - comboBox3 = new JComboBox<>(); - spinnerLabel = new JLabel(); - spinner1 = new JSpinner(); - textFieldLabel = new JLabel(); + focusedCheckBox = new JCheckBox(); + JLabel labelLabel = new JLabel(); + JLabel label1 = new JLabel(); + FlatButton flatButton1 = new FlatButton(); + JLabel buttonLabel = new JLabel(); + JButton button1 = new JButton(); + FlatThemePreviewAll.PreviewDefaultButton testDefaultButton1 = new FlatThemePreviewAll.PreviewDefaultButton(); + FlatButton helpButton = new FlatButton(); + JPanel hSpacer2 = new JPanel(null); + JLabel toggleButtonLabel = new JLabel(); + JToggleButton toggleButton1 = new JToggleButton(); + JToggleButton toggleButton3 = new JToggleButton(); + JPanel hSpacer1 = new JPanel(null); + JLabel checkBoxLabel = new JLabel(); + JCheckBox checkBox1 = new JCheckBox(); + JCheckBox checkBox3 = new JCheckBox(); + JPanel hSpacer3 = new JPanel(null); + JLabel radioButtonLabel = new JLabel(); + JRadioButton radioButton1 = new JRadioButton(); + JRadioButton radioButton3 = new JRadioButton(); + JPanel hSpacer4 = new JPanel(null); + JLabel comboBoxLabel = new JLabel(); + FlatComboBox comboBox1 = new FlatComboBox<>(); + JComboBox comboBox3 = new JComboBox<>(); + JLabel spinnerLabel = new JLabel(); + JSpinner spinner1 = new JSpinner(); + JLabel textFieldLabel = new JLabel(); textField1 = new FlatTextField(); - formattedTextField1 = new FlatFormattedTextField(); - passwordField1 = new FlatPasswordField(); - textAreaLabel = new JLabel(); - scrollPane1 = new JScrollPane(); - textArea1 = new JTextArea(); - scrollPane5 = new JScrollPane(); - editorPane1 = new JEditorPane(); - scrollPane9 = new JScrollPane(); - textPane1 = new JTextPane(); - menuBarLabel = new JLabel(); - menuBar1 = new JMenuBar(); + FlatFormattedTextField formattedTextField1 = new FlatFormattedTextField(); + FlatPasswordField passwordField1 = new FlatPasswordField(); + JLabel textAreaLabel = new JLabel(); + JScrollPane scrollPane1 = new JScrollPane(); + JTextArea textArea1 = new JTextArea(); + JScrollPane scrollPane5 = new JScrollPane(); + JEditorPane editorPane1 = new JEditorPane(); + JScrollPane scrollPane9 = new JScrollPane(); + JTextPane textPane1 = new JTextPane(); + JLabel menuBarLabel = new JLabel(); + JMenuBar menuBar1 = new JMenuBar(); menu2 = new JMenu(); - menuItem3 = new JMenuItem(); - menuItem4 = new JMenuItem(); - checkBoxMenuItem2 = new JCheckBoxMenuItem(); - checkBoxMenuItem3 = new JCheckBoxMenuItem(); - radioButtonMenuItem4 = new JRadioButtonMenuItem(); - radioButtonMenuItem5 = new JRadioButtonMenuItem(); - menu4 = new JMenu(); - menuItem6 = new JMenuItem(); - menu5 = new JMenu(); - menuItem7 = new JMenuItem(); - menu3 = new JMenu(); - menuItem5 = new JMenuItem(); - menuItem8 = new JMenuItem(); - menuItem9 = new JMenuItem(); - scrollBarLabel = new JLabel(); - scrollBar1 = new JScrollBar(); - scrollBar5 = new FlatScrollBar(); - separatorLabel = new JLabel(); - separator1 = new JSeparator(); - sliderLabel = new JLabel(); + JMenuItem menuItem3 = new JMenuItem(); + JMenuItem menuItem4 = new JMenuItem(); + JCheckBoxMenuItem checkBoxMenuItem2 = new JCheckBoxMenuItem(); + JCheckBoxMenuItem checkBoxMenuItem3 = new JCheckBoxMenuItem(); + JRadioButtonMenuItem radioButtonMenuItem4 = new JRadioButtonMenuItem(); + JRadioButtonMenuItem radioButtonMenuItem5 = new JRadioButtonMenuItem(); + JMenu menu4 = new JMenu(); + JMenuItem menuItem6 = new JMenuItem(); + JMenu menu5 = new JMenu(); + JMenuItem menuItem7 = new JMenuItem(); + JMenu menu3 = new JMenu(); + JMenuItem menuItem5 = new JMenuItem(); + JMenuItem menuItem8 = new JMenuItem(); + JMenuItem menuItem9 = new JMenuItem(); + JLabel scrollBarLabel = new JLabel(); + JScrollBar scrollBar1 = new JScrollBar(); + FlatScrollBar scrollBar5 = new FlatScrollBar(); + JLabel separatorLabel = new JLabel(); + JSeparator separator1 = new JSeparator(); + JLabel sliderLabel = new JLabel(); slider1 = new JSlider(); slider3 = new JSlider(); - progressBarLabel = new JLabel(); + JLabel progressBarLabel = new JLabel(); progressBar1 = new FlatProgressBar(); progressBar2 = new FlatProgressBar(); - toolTipLabel = new JLabel(); - toolTip1 = new JToolTip(); - toolBarLabel = new JLabel(); + JLabel toolTipLabel = new JLabel(); + JToolTip toolTip1 = new JToolTip(); + JLabel toolBarLabel = new JLabel(); toolBar1 = new JToolBar(); - button4 = new JButton(); - button6 = new JButton(); - button7 = new JToggleButton(); - button8 = new JToggleButton(); - tabbedPaneLabel = new JLabel(); + JButton button4 = new JButton(); + JButton button6 = new JButton(); + JToggleButton button7 = new JToggleButton(); + JToggleButton button8 = new JToggleButton(); + JLabel tabbedPaneLabel = new JLabel(); tabbedPane1 = new FlatThemePreviewAll.PreviewTabbedPane(); - listTreeLabel = new JLabel(); - splitPane1 = new JSplitPane(); - scrollPane2 = new JScrollPane(); + JLabel listTreeLabel = new JLabel(); + JSplitPane splitPane1 = new JSplitPane(); + JScrollPane scrollPane2 = new JScrollPane(); list1 = new JList<>(); - scrollPane3 = new JScrollPane(); + JScrollPane scrollPane3 = new JScrollPane(); tree1 = new JTree(); - tableLabel = new JLabel(); - scrollPane4 = new JScrollPane(); + JLabel tableLabel = new JLabel(); + JScrollPane scrollPane4 = new JScrollPane(); table1 = new FlatThemePreviewAll.PreviewTable(); - internalFrameLabel = new JLabel(); + JLabel internalFrameLabel = new JLabel(); desktopPane1 = new JDesktopPane(); internalFrame1 = new JInternalFrame(); internalFrame2 = new JInternalFrame(); @@ -263,6 +296,11 @@ class FlatThemePreviewAll enabledCheckBox.addActionListener(e -> enabledChanged()); add(enabledCheckBox, "cell 0 0 2 1,alignx left,growx 0"); + //---- focusedCheckBox ---- + focusedCheckBox.setText("Focused"); + focusedCheckBox.addActionListener(e -> focusedChanged()); + add(focusedCheckBox, "cell 0 0 2 1"); + //---- labelLabel ---- labelLabel.setText("JLabel:"); add(labelLabel, "cell 0 1"); @@ -729,90 +767,18 @@ class FlatThemePreviewAll // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables private JCheckBox enabledCheckBox; - private JLabel labelLabel; - private JLabel label1; - private FlatButton flatButton1; - private JLabel buttonLabel; - private JButton button1; - private FlatThemePreviewAll.PreviewDefaultButton testDefaultButton1; - private FlatButton helpButton; - private JPanel hSpacer2; - private JLabel toggleButtonLabel; - private JToggleButton toggleButton1; - private JToggleButton toggleButton3; - private JPanel hSpacer1; - private JLabel checkBoxLabel; - private JCheckBox checkBox1; - private JCheckBox checkBox3; - private JPanel hSpacer3; - private JLabel radioButtonLabel; - private JRadioButton radioButton1; - private JRadioButton radioButton3; - private JPanel hSpacer4; - private JLabel comboBoxLabel; - private FlatComboBox comboBox1; - private JComboBox comboBox3; - private JLabel spinnerLabel; - private JSpinner spinner1; - private JLabel textFieldLabel; + private JCheckBox focusedCheckBox; private FlatTextField textField1; - private FlatFormattedTextField formattedTextField1; - private FlatPasswordField passwordField1; - private JLabel textAreaLabel; - private JScrollPane scrollPane1; - private JTextArea textArea1; - private JScrollPane scrollPane5; - private JEditorPane editorPane1; - private JScrollPane scrollPane9; - private JTextPane textPane1; - private JLabel menuBarLabel; - private JMenuBar menuBar1; private JMenu menu2; - private JMenuItem menuItem3; - private JMenuItem menuItem4; - private JCheckBoxMenuItem checkBoxMenuItem2; - private JCheckBoxMenuItem checkBoxMenuItem3; - private JRadioButtonMenuItem radioButtonMenuItem4; - private JRadioButtonMenuItem radioButtonMenuItem5; - private JMenu menu4; - private JMenuItem menuItem6; - private JMenu menu5; - private JMenuItem menuItem7; - private JMenu menu3; - private JMenuItem menuItem5; - private JMenuItem menuItem8; - private JMenuItem menuItem9; - private JLabel scrollBarLabel; - private JScrollBar scrollBar1; - private FlatScrollBar scrollBar5; - private JLabel separatorLabel; - private JSeparator separator1; - private JLabel sliderLabel; private JSlider slider1; private JSlider slider3; - private JLabel progressBarLabel; private FlatProgressBar progressBar1; private FlatProgressBar progressBar2; - private JLabel toolTipLabel; - private JToolTip toolTip1; - private JLabel toolBarLabel; private JToolBar toolBar1; - private JButton button4; - private JButton button6; - private JToggleButton button7; - private JToggleButton button8; - private JLabel tabbedPaneLabel; private FlatThemePreviewAll.PreviewTabbedPane tabbedPane1; - private JLabel listTreeLabel; - private JSplitPane splitPane1; - private JScrollPane scrollPane2; private JList list1; - private JScrollPane scrollPane3; private JTree tree1; - private JLabel tableLabel; - private JScrollPane scrollPane4; private FlatThemePreviewAll.PreviewTable table1; - private JLabel internalFrameLabel; private JDesktopPane desktopPane1; private JInternalFrame internalFrame1; private JInternalFrame internalFrame2; diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.jfd b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.jfd index 563a63bb..34b3de15 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.jfd +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.jfd @@ -3,6 +3,9 @@ JFDML JFormDesigner: "7.0.4.0.360" Java: "16" encoding: "UTF-8" new FormModel { contentType: "form/swing" root: new FormRoot { + auxiliary() { + "JavaCodeGenerator.defaultVariableLocal": true + } add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets dialog,hidemode 3" "$columnConstraints": "[fill][130,fill]" @@ -13,10 +16,23 @@ new FormModel { name: "enabledCheckBox" "text": "Enabled" "selected": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "enabledChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 0 2 1,alignx left,growx 0" } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "focusedCheckBox" + "text": "Focused" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "focusedChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0 2 1" + } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "labelLabel" "text": "JLabel:" @@ -285,6 +301,9 @@ new FormModel { add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { name: "menu2" "text": "JMenu" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } add( new FormComponent( "javax.swing.JMenuItem" ) { name: "menuItem3" "text": "JMenuItem" @@ -426,6 +445,9 @@ new FormModel { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatProgressBar" ) { name: "progressBar1" "value": 60 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 18" } ) @@ -433,6 +455,9 @@ new FormModel { name: "progressBar2" "value": 50 "stringPainted": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 19" } ) @@ -456,6 +481,9 @@ new FormModel { } ) add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { name: "toolBar1" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } add( new FormComponent( "javax.swing.JButton" ) { name: "button4" "icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" ) @@ -487,6 +515,9 @@ new FormModel { } ) add( new FormContainer( "com.formdev.flatlaf.themeeditor.FlatThemePreviewAll$PreviewTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { name: "tabbedPane1" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 22" } ) @@ -509,6 +540,9 @@ new FormModel { addElement( "Item 2" ) addElement( "Item 3" ) } + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } } ) }, new FormLayoutConstraints( class java.lang.String ) { "value": "left" @@ -528,6 +562,9 @@ new FormModel { userObject: "Item 3" } ) } ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } } ) }, new FormLayoutConstraints( class java.lang.String ) { "value": "right" @@ -567,6 +604,9 @@ new FormModel { add( null ) add( null ) } ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 24,height 70" @@ -579,6 +619,9 @@ new FormModel { } ) add( new FormContainer( "javax.swing.JDesktopPane", new FormLayoutManager( class javax.swing.JDesktopPane ) ) { name: "desktopPane1" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } add( new FormContainer( "javax.swing.JInternalFrame", new FormLayoutManager( class java.awt.BorderLayout ) ) { name: "internalFrame1" "visible": true @@ -587,6 +630,9 @@ new FormModel { "maximizable": true "iconifiable": true "resizable": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( null ) { "x": 5 "y": 5 @@ -599,6 +645,9 @@ new FormModel { "maximizable": true "resizable": true "title": "Inactive" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } }, new FormLayoutConstraints( null ) { "x": 5 "y": 50 diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.java index 611876fb..d79e9592 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.java @@ -16,6 +16,8 @@ package com.formdev.flatlaf.themeeditor; +import java.awt.Component; +import java.util.Objects; import java.util.function.Predicate; import javax.swing.*; import com.formdev.flatlaf.FlatClientProperties; @@ -31,76 +33,113 @@ class FlatThemePreviewButtons initComponents(); } + private void buttonTypeChanged() { + Object buttonType = null; + if( squareButton.isSelected() ) + buttonType = FlatClientProperties.BUTTON_TYPE_SQUARE; + else if( roundRectButton.isSelected() ) + buttonType = FlatClientProperties.BUTTON_TYPE_ROUND_RECT; + else if( tabButton.isSelected() ) + buttonType = FlatClientProperties.BUTTON_TYPE_TAB; + else if( toolBarButtonButton.isSelected() ) + buttonType = FlatClientProperties.BUTTON_TYPE_TOOLBAR_BUTTON; + else if( borderlessButton.isSelected() ) + buttonType = FlatClientProperties.BUTTON_TYPE_BORDERLESS; + + for( Component c : getComponents() ) { + if( !(c instanceof AbstractButton) ) + continue; + + AbstractButton b = (AbstractButton) c; + if( !Objects.equals( b.getClientProperty( FlatClientProperties.BUTTON_TYPE ), FlatClientProperties.BUTTON_TYPE_HELP ) ) + b.putClientProperty( FlatClientProperties.BUTTON_TYPE, buttonType ); + } + } + private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents - label11 = new JLabel(); - label5 = new JLabel(); - label7 = new JLabel(); - label6 = new JLabel(); - label8 = new JLabel(); - label1 = new JLabel(); - testStateButton1 = new FlatThemePreviewButtons.TestStateButton(); - testStateButton7 = new FlatThemePreviewButtons.TestStateButton(); - testStateButton4 = new FlatThemePreviewButtons.TestStateButton(); - testStateButton10 = new FlatThemePreviewButtons.TestStateButton(); - label2 = new JLabel(); - testStateButton2 = new FlatThemePreviewButtons.TestStateButton(); - testStateButton8 = new FlatThemePreviewButtons.TestStateButton(); - testStateButton5 = new FlatThemePreviewButtons.TestStateButton(); - testStateButton11 = new FlatThemePreviewButtons.TestStateButton(); - label3 = new JLabel(); - testStateButton3 = new FlatThemePreviewButtons.TestStateButton(); - testStateButton9 = new FlatThemePreviewButtons.TestStateButton(); - testStateButton6 = new FlatThemePreviewButtons.TestStateButton(); - testStateButton12 = new FlatThemePreviewButtons.TestStateButton(); - label4 = new JLabel(); - testStateButton13 = new FlatThemePreviewButtons.TestStateButton(); - testStateButton14 = new FlatThemePreviewButtons.TestStateButton(); - label10 = new JLabel(); - button1 = new JButton(); - testDefaultButton1 = new FlatThemePreviewButtons.TestDefaultButton(); - label12 = new JLabel(); - label13 = new JLabel(); - label14 = new JLabel(); - label15 = new JLabel(); - label16 = new JLabel(); - label17 = new JLabel(); - testStateToggleButton1 = new FlatThemePreviewButtons.TestStateToggleButton(); - testStateToggleButton5 = new FlatThemePreviewButtons.TestStateToggleButton(); - testStateToggleButton9 = new FlatThemePreviewButtons.TestStateToggleButton(); - testStateToggleButton12 = new FlatThemePreviewButtons.TestStateToggleButton(); - label18 = new JLabel(); - testStateToggleButton2 = new FlatThemePreviewButtons.TestStateToggleButton(); - testStateToggleButton6 = new FlatThemePreviewButtons.TestStateToggleButton(); - testStateToggleButton10 = new FlatThemePreviewButtons.TestStateToggleButton(); - testStateToggleButton13 = new FlatThemePreviewButtons.TestStateToggleButton(); - label19 = new JLabel(); - testStateToggleButton3 = new FlatThemePreviewButtons.TestStateToggleButton(); - testStateToggleButton7 = new FlatThemePreviewButtons.TestStateToggleButton(); - testStateToggleButton11 = new FlatThemePreviewButtons.TestStateToggleButton(); - testStateToggleButton14 = new FlatThemePreviewButtons.TestStateToggleButton(); - label20 = new JLabel(); - testStateToggleButton4 = new FlatThemePreviewButtons.TestStateToggleButton(); - testStateToggleButton8 = new FlatThemePreviewButtons.TestStateToggleButton(); - label21 = new JLabel(); - toggleButton1 = new JToggleButton(); - toggleButton2 = new JToggleButton(); - label32 = new JLabel(); - label9 = new JLabel(); - label33 = new JLabel(); - label22 = new JLabel(); - testStateButton15 = new FlatThemePreviewButtons.TestStateButton(); - testStateButton19 = new FlatThemePreviewButtons.TestStateButton(); - label23 = new JLabel(); - testStateButton16 = new FlatThemePreviewButtons.TestStateButton(); - testStateButton20 = new FlatThemePreviewButtons.TestStateButton(); - label24 = new JLabel(); - testStateButton17 = new FlatThemePreviewButtons.TestStateButton(); - testStateButton21 = new FlatThemePreviewButtons.TestStateButton(); - label25 = new JLabel(); - testStateButton18 = new FlatThemePreviewButtons.TestStateButton(); - label26 = new JLabel(); - button2 = new JButton(); + JPanel panel1 = new JPanel(); + JLabel buttonTypeLabel = new JLabel(); + JToolBar buttonTypeToolBar1 = new JToolBar(); + noneButton = new JToggleButton(); + squareButton = new JToggleButton(); + roundRectButton = new JToggleButton(); + tabButton = new JToggleButton(); + JToolBar buttonTypeToolBar2 = new JToolBar(); + toolBarButtonButton = new JToggleButton(); + borderlessButton = new JToggleButton(); + JLabel label11 = new JLabel(); + JLabel label27 = new JLabel(); + JLabel label28 = new JLabel(); + JLabel label5 = new JLabel(); + JLabel label7 = new JLabel(); + JLabel label6 = new JLabel(); + JLabel label8 = new JLabel(); + JLabel label1 = new JLabel(); + FlatThemePreviewButtons.TestStateButton testStateButton1 = new FlatThemePreviewButtons.TestStateButton(); + FlatThemePreviewButtons.TestStateButton testStateButton7 = new FlatThemePreviewButtons.TestStateButton(); + FlatThemePreviewButtons.TestStateButton testStateButton4 = new FlatThemePreviewButtons.TestStateButton(); + FlatThemePreviewButtons.TestStateButton testStateButton10 = new FlatThemePreviewButtons.TestStateButton(); + JLabel label2 = new JLabel(); + FlatThemePreviewButtons.TestStateButton testStateButton2 = new FlatThemePreviewButtons.TestStateButton(); + FlatThemePreviewButtons.TestStateButton testStateButton8 = new FlatThemePreviewButtons.TestStateButton(); + FlatThemePreviewButtons.TestStateButton testStateButton5 = new FlatThemePreviewButtons.TestStateButton(); + FlatThemePreviewButtons.TestStateButton testStateButton11 = new FlatThemePreviewButtons.TestStateButton(); + JLabel label3 = new JLabel(); + FlatThemePreviewButtons.TestStateButton testStateButton3 = new FlatThemePreviewButtons.TestStateButton(); + FlatThemePreviewButtons.TestStateButton testStateButton9 = new FlatThemePreviewButtons.TestStateButton(); + FlatThemePreviewButtons.TestStateButton testStateButton6 = new FlatThemePreviewButtons.TestStateButton(); + FlatThemePreviewButtons.TestStateButton testStateButton12 = new FlatThemePreviewButtons.TestStateButton(); + JLabel label4 = new JLabel(); + FlatThemePreviewButtons.TestStateButton testStateButton13 = new FlatThemePreviewButtons.TestStateButton(); + FlatThemePreviewButtons.TestStateButton testStateButton14 = new FlatThemePreviewButtons.TestStateButton(); + JLabel label10 = new JLabel(); + JButton button1 = new JButton(); + FlatThemePreviewButtons.TestDefaultButton testDefaultButton1 = new FlatThemePreviewButtons.TestDefaultButton(); + JLabel label12 = new JLabel(); + JLabel label29 = new JLabel(); + JLabel label30 = new JLabel(); + JLabel label13 = new JLabel(); + JLabel label14 = new JLabel(); + JLabel label15 = new JLabel(); + JLabel label16 = new JLabel(); + JLabel label17 = new JLabel(); + FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton1 = new FlatThemePreviewButtons.TestStateToggleButton(); + FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton5 = new FlatThemePreviewButtons.TestStateToggleButton(); + FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton9 = new FlatThemePreviewButtons.TestStateToggleButton(); + FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton12 = new FlatThemePreviewButtons.TestStateToggleButton(); + JLabel label18 = new JLabel(); + FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton2 = new FlatThemePreviewButtons.TestStateToggleButton(); + FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton6 = new FlatThemePreviewButtons.TestStateToggleButton(); + FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton10 = new FlatThemePreviewButtons.TestStateToggleButton(); + FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton13 = new FlatThemePreviewButtons.TestStateToggleButton(); + JLabel label19 = new JLabel(); + FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton3 = new FlatThemePreviewButtons.TestStateToggleButton(); + FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton7 = new FlatThemePreviewButtons.TestStateToggleButton(); + FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton11 = new FlatThemePreviewButtons.TestStateToggleButton(); + FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton14 = new FlatThemePreviewButtons.TestStateToggleButton(); + JLabel label20 = new JLabel(); + FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton4 = new FlatThemePreviewButtons.TestStateToggleButton(); + FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton8 = new FlatThemePreviewButtons.TestStateToggleButton(); + JLabel label21 = new JLabel(); + JToggleButton toggleButton1 = new JToggleButton(); + JToggleButton toggleButton2 = new JToggleButton(); + JLabel label32 = new JLabel(); + JLabel label9 = new JLabel(); + JLabel label33 = new JLabel(); + JLabel label22 = new JLabel(); + FlatThemePreviewButtons.TestStateButton testStateButton15 = new FlatThemePreviewButtons.TestStateButton(); + FlatThemePreviewButtons.TestStateButton testStateButton19 = new FlatThemePreviewButtons.TestStateButton(); + JLabel label23 = new JLabel(); + FlatThemePreviewButtons.TestStateButton testStateButton16 = new FlatThemePreviewButtons.TestStateButton(); + FlatThemePreviewButtons.TestStateButton testStateButton20 = new FlatThemePreviewButtons.TestStateButton(); + JLabel label24 = new JLabel(); + FlatThemePreviewButtons.TestStateButton testStateButton17 = new FlatThemePreviewButtons.TestStateButton(); + FlatThemePreviewButtons.TestStateButton testStateButton21 = new FlatThemePreviewButtons.TestStateButton(); + JLabel label25 = new JLabel(); + FlatThemePreviewButtons.TestStateButton testStateButton18 = new FlatThemePreviewButtons.TestStateButton(); + JLabel label26 = new JLabel(); + JButton button2 = new JButton(); //======== this ======== setLayout(new MigLayout( @@ -112,7 +151,9 @@ class FlatThemePreviewButtons "[fill]" + "[fill]para", // rows + "[]para" + "[]" + + "[]0" + "[]" + "[]" + "[]" + @@ -120,6 +161,7 @@ class FlatThemePreviewButtons "[]unrel" + "[]para" + "[]" + + "[]0" + "[]" + "[]" + "[]" + @@ -134,78 +176,158 @@ class FlatThemePreviewButtons "[]unrel" + "[]")); + //======== panel1 ======== + { + panel1.setLayout(new MigLayout( + "insets 0,hidemode 3", + // columns + "[fill]" + + "[fill]", + // rows + "[]0" + + "[]")); + + //---- buttonTypeLabel ---- + buttonTypeLabel.setText("Button type:"); + panel1.add(buttonTypeLabel, "cell 0 0"); + + //======== buttonTypeToolBar1 ======== + { + buttonTypeToolBar1.setFloatable(false); + buttonTypeToolBar1.setBorder(BorderFactory.createEmptyBorder()); + + //---- noneButton ---- + noneButton.setText("none"); + noneButton.setSelected(true); + noneButton.setFont(noneButton.getFont().deriveFont(noneButton.getFont().getSize() - 2f)); + noneButton.addActionListener(e -> buttonTypeChanged()); + buttonTypeToolBar1.add(noneButton); + + //---- squareButton ---- + squareButton.setText("square"); + squareButton.setFont(squareButton.getFont().deriveFont(squareButton.getFont().getSize() - 2f)); + squareButton.addActionListener(e -> buttonTypeChanged()); + buttonTypeToolBar1.add(squareButton); + + //---- roundRectButton ---- + roundRectButton.setText("roundRect"); + roundRectButton.setFont(roundRectButton.getFont().deriveFont(roundRectButton.getFont().getSize() - 2f)); + roundRectButton.addActionListener(e -> buttonTypeChanged()); + buttonTypeToolBar1.add(roundRectButton); + + //---- tabButton ---- + tabButton.setText("tab"); + tabButton.setFont(tabButton.getFont().deriveFont(tabButton.getFont().getSize() - 2f)); + tabButton.addActionListener(e -> buttonTypeChanged()); + buttonTypeToolBar1.add(tabButton); + } + panel1.add(buttonTypeToolBar1, "cell 1 0"); + + //======== buttonTypeToolBar2 ======== + { + buttonTypeToolBar2.setFloatable(false); + buttonTypeToolBar2.setBorder(BorderFactory.createEmptyBorder()); + + //---- toolBarButtonButton ---- + toolBarButtonButton.setText("toolBarButton"); + toolBarButtonButton.setFont(toolBarButtonButton.getFont().deriveFont(toolBarButtonButton.getFont().getSize() - 2f)); + toolBarButtonButton.addActionListener(e -> buttonTypeChanged()); + buttonTypeToolBar2.add(toolBarButtonButton); + + //---- borderlessButton ---- + borderlessButton.setText("borderless"); + borderlessButton.setFont(borderlessButton.getFont().deriveFont(borderlessButton.getFont().getSize() - 2f)); + borderlessButton.addActionListener(e -> buttonTypeChanged()); + buttonTypeToolBar2.add(borderlessButton); + } + panel1.add(buttonTypeToolBar2, "cell 1 1"); + } + add(panel1, "cell 0 0 5 1"); + //---- label11 ---- label11.setText("JButton"); label11.setFont(label11.getFont().deriveFont(label11.getFont().getSize() + 4f)); - add(label11, "cell 0 0 3 1"); + add(label11, "cell 0 1 3 1"); + + //---- label27 ---- + label27.setText("unfocused"); + add(label27, "cell 1 2 2 1,alignx center,growx 0"); + + //---- label28 ---- + label28.setText("focused"); + add(label28, "cell 3 2 2 1,alignx center,growx 0"); //---- label5 ---- label5.setText("regular"); - add(label5, "cell 1 1"); + label5.setFont(label5.getFont().deriveFont(label5.getFont().getSize() - 2f)); + add(label5, "cell 1 3"); //---- label7 ---- label7.setText("default"); - add(label7, "cell 2 1"); + label7.setFont(label7.getFont().deriveFont(label7.getFont().getSize() - 2f)); + add(label7, "cell 2 3"); //---- label6 ---- - label6.setText("focused"); - add(label6, "cell 3 1"); + label6.setText("regular"); + label6.setFont(label6.getFont().deriveFont(label6.getFont().getSize() - 2f)); + add(label6, "cell 3 3"); //---- label8 ---- label8.setText("default"); - add(label8, "cell 4 1"); + label8.setFont(label8.getFont().deriveFont(label8.getFont().getSize() - 2f)); + add(label8, "cell 4 3"); //---- label1 ---- label1.setText("none"); - add(label1, "cell 0 2"); + add(label1, "cell 0 4"); //---- testStateButton1 ---- testStateButton1.setText("OK"); testStateButton1.putClientProperty("JComponent.minimumWidth", 0); - add(testStateButton1, "cell 1 2"); + add(testStateButton1, "cell 1 4"); //---- testStateButton7 ---- testStateButton7.setText("OK"); testStateButton7.setStateDefault(true); testStateButton7.putClientProperty("JComponent.minimumWidth", 0); - add(testStateButton7, "cell 2 2"); + add(testStateButton7, "cell 2 4"); //---- testStateButton4 ---- testStateButton4.setText("OK"); testStateButton4.setStateFocused(true); testStateButton4.putClientProperty("JComponent.minimumWidth", 0); - add(testStateButton4, "cell 3 2"); + add(testStateButton4, "cell 3 4"); //---- testStateButton10 ---- testStateButton10.setText("OK"); testStateButton10.setStateFocused(true); testStateButton10.setStateDefault(true); testStateButton10.putClientProperty("JComponent.minimumWidth", 0); - add(testStateButton10, "cell 4 2"); + add(testStateButton10, "cell 4 4"); //---- label2 ---- label2.setText("hover"); - add(label2, "cell 0 3"); + add(label2, "cell 0 5"); //---- testStateButton2 ---- testStateButton2.setText("OK"); testStateButton2.setStateHover(true); testStateButton2.putClientProperty("JComponent.minimumWidth", 0); - add(testStateButton2, "cell 1 3"); + add(testStateButton2, "cell 1 5"); //---- testStateButton8 ---- testStateButton8.setText("OK"); testStateButton8.setStateHover(true); testStateButton8.setStateDefault(true); testStateButton8.putClientProperty("JComponent.minimumWidth", 0); - add(testStateButton8, "cell 2 3"); + add(testStateButton8, "cell 2 5"); //---- testStateButton5 ---- testStateButton5.setText("OK"); testStateButton5.setStateHover(true); testStateButton5.setStateFocused(true); testStateButton5.putClientProperty("JComponent.minimumWidth", 0); - add(testStateButton5, "cell 3 3"); + add(testStateButton5, "cell 3 5"); //---- testStateButton11 ---- testStateButton11.setText("OK"); @@ -213,31 +335,31 @@ class FlatThemePreviewButtons testStateButton11.setStateFocused(true); testStateButton11.setStateDefault(true); testStateButton11.putClientProperty("JComponent.minimumWidth", 0); - add(testStateButton11, "cell 4 3"); + add(testStateButton11, "cell 4 5"); //---- label3 ---- label3.setText("pressed"); - add(label3, "cell 0 4"); + add(label3, "cell 0 6"); //---- testStateButton3 ---- testStateButton3.setText("OK"); testStateButton3.setStatePressed(true); testStateButton3.putClientProperty("JComponent.minimumWidth", 0); - add(testStateButton3, "cell 1 4"); + add(testStateButton3, "cell 1 6"); //---- testStateButton9 ---- testStateButton9.setText("OK"); testStateButton9.setStatePressed(true); testStateButton9.setStateDefault(true); testStateButton9.putClientProperty("JComponent.minimumWidth", 0); - add(testStateButton9, "cell 2 4"); + add(testStateButton9, "cell 2 6"); //---- testStateButton6 ---- testStateButton6.setText("OK"); testStateButton6.setStatePressed(true); testStateButton6.setStateFocused(true); testStateButton6.putClientProperty("JComponent.minimumWidth", 0); - add(testStateButton6, "cell 3 4"); + add(testStateButton6, "cell 3 6"); //---- testStateButton12 ---- testStateButton12.setText("OK"); @@ -245,320 +367,279 @@ class FlatThemePreviewButtons testStateButton12.setStateFocused(true); testStateButton12.setStateDefault(true); testStateButton12.putClientProperty("JComponent.minimumWidth", 0); - add(testStateButton12, "cell 4 4"); + add(testStateButton12, "cell 4 6"); //---- label4 ---- label4.setText("disabled"); - add(label4, "cell 0 5"); + add(label4, "cell 0 7"); //---- testStateButton13 ---- testStateButton13.setText("OK"); testStateButton13.setEnabled(false); testStateButton13.putClientProperty("JComponent.minimumWidth", 0); - add(testStateButton13, "cell 1 5"); + add(testStateButton13, "cell 1 7"); //---- testStateButton14 ---- testStateButton14.setText("OK"); testStateButton14.setEnabled(false); testStateButton14.setStateDefault(true); testStateButton14.putClientProperty("JComponent.minimumWidth", 0); - add(testStateButton14, "cell 2 5"); + add(testStateButton14, "cell 2 7"); //---- label10 ---- label10.setText("try me"); - add(label10, "cell 0 6"); + add(label10, "cell 0 8"); //---- button1 ---- button1.setText("OK"); button1.putClientProperty("JComponent.minimumWidth", 0); - add(button1, "cell 1 6"); + add(button1, "cell 1 8"); //---- testDefaultButton1 ---- testDefaultButton1.setText("OK"); testDefaultButton1.putClientProperty("JComponent.minimumWidth", 0); - add(testDefaultButton1, "cell 2 6"); + add(testDefaultButton1, "cell 2 8"); //---- label12 ---- label12.setText("JToggleButton"); label12.setFont(label12.getFont().deriveFont(label12.getFont().getSize() + 4f)); - add(label12, "cell 0 7 3 1"); + add(label12, "cell 0 9 3 1"); + + //---- label29 ---- + label29.setText("unfocused"); + add(label29, "cell 1 10 2 1,alignx center,growx 0"); + + //---- label30 ---- + label30.setText("focused"); + add(label30, "cell 3 10 2 1,alignx center,growx 0"); //---- label13 ---- label13.setText("unsel."); - add(label13, "cell 1 8"); + label13.setFont(label13.getFont().deriveFont(label13.getFont().getSize() - 2f)); + add(label13, "cell 1 11"); //---- label14 ---- label14.setText("selected"); - add(label14, "cell 2 8"); + label14.setFont(label14.getFont().deriveFont(label14.getFont().getSize() - 2f)); + add(label14, "cell 2 11"); //---- label15 ---- - label15.setText("focused"); - add(label15, "cell 3 8"); + label15.setText("unsel."); + label15.setFont(label15.getFont().deriveFont(label15.getFont().getSize() - 2f)); + add(label15, "cell 3 11"); //---- label16 ---- label16.setText("selected"); - add(label16, "cell 4 8"); + label16.setFont(label16.getFont().deriveFont(label16.getFont().getSize() - 2f)); + add(label16, "cell 4 11"); //---- label17 ---- label17.setText("none"); - add(label17, "cell 0 9"); + add(label17, "cell 0 12"); //---- testStateToggleButton1 ---- testStateToggleButton1.setText("OK"); - add(testStateToggleButton1, "cell 1 9"); + add(testStateToggleButton1, "cell 1 12"); //---- testStateToggleButton5 ---- testStateToggleButton5.setText("OK"); testStateToggleButton5.setStateSelected(true); - add(testStateToggleButton5, "cell 2 9"); + add(testStateToggleButton5, "cell 2 12"); //---- testStateToggleButton9 ---- testStateToggleButton9.setText("OK"); testStateToggleButton9.setStateFocused(true); - add(testStateToggleButton9, "cell 3 9"); + add(testStateToggleButton9, "cell 3 12"); //---- testStateToggleButton12 ---- testStateToggleButton12.setText("OK"); testStateToggleButton12.setStateSelected(true); testStateToggleButton12.setStateFocused(true); - add(testStateToggleButton12, "cell 4 9"); + add(testStateToggleButton12, "cell 4 12"); //---- label18 ---- label18.setText("hover"); - add(label18, "cell 0 10"); + add(label18, "cell 0 13"); //---- testStateToggleButton2 ---- testStateToggleButton2.setText("OK"); testStateToggleButton2.setStateHover(true); - add(testStateToggleButton2, "cell 1 10"); + add(testStateToggleButton2, "cell 1 13"); //---- testStateToggleButton6 ---- testStateToggleButton6.setText("OK"); testStateToggleButton6.setStateHover(true); testStateToggleButton6.setStateSelected(true); - add(testStateToggleButton6, "cell 2 10"); + add(testStateToggleButton6, "cell 2 13"); //---- testStateToggleButton10 ---- testStateToggleButton10.setText("OK"); testStateToggleButton10.setStateHover(true); testStateToggleButton10.setStateFocused(true); - add(testStateToggleButton10, "cell 3 10"); + add(testStateToggleButton10, "cell 3 13"); //---- testStateToggleButton13 ---- testStateToggleButton13.setText("OK"); testStateToggleButton13.setStateHover(true); testStateToggleButton13.setStateSelected(true); testStateToggleButton13.setStateFocused(true); - add(testStateToggleButton13, "cell 4 10"); + add(testStateToggleButton13, "cell 4 13"); //---- label19 ---- label19.setText("pressed"); - add(label19, "cell 0 11"); + add(label19, "cell 0 14"); //---- testStateToggleButton3 ---- testStateToggleButton3.setText("OK"); testStateToggleButton3.setStatePressed(true); - add(testStateToggleButton3, "cell 1 11"); + add(testStateToggleButton3, "cell 1 14"); //---- testStateToggleButton7 ---- testStateToggleButton7.setText("OK"); testStateToggleButton7.setStatePressed(true); testStateToggleButton7.setStateSelected(true); - add(testStateToggleButton7, "cell 2 11"); + add(testStateToggleButton7, "cell 2 14"); //---- testStateToggleButton11 ---- testStateToggleButton11.setText("OK"); testStateToggleButton11.setStatePressed(true); testStateToggleButton11.setStateFocused(true); - add(testStateToggleButton11, "cell 3 11"); + add(testStateToggleButton11, "cell 3 14"); //---- testStateToggleButton14 ---- testStateToggleButton14.setText("OK"); testStateToggleButton14.setStatePressed(true); testStateToggleButton14.setStateSelected(true); testStateToggleButton14.setStateFocused(true); - add(testStateToggleButton14, "cell 4 11"); + add(testStateToggleButton14, "cell 4 14"); //---- label20 ---- label20.setText("disabled"); - add(label20, "cell 0 12"); + add(label20, "cell 0 15"); //---- testStateToggleButton4 ---- testStateToggleButton4.setText("OK"); testStateToggleButton4.setEnabled(false); - add(testStateToggleButton4, "cell 1 12"); + add(testStateToggleButton4, "cell 1 15"); //---- testStateToggleButton8 ---- testStateToggleButton8.setText("OK"); testStateToggleButton8.setEnabled(false); testStateToggleButton8.setStateSelected(true); - add(testStateToggleButton8, "cell 2 12"); + add(testStateToggleButton8, "cell 2 15"); //---- label21 ---- label21.setText("try me"); - add(label21, "cell 0 13"); + add(label21, "cell 0 16"); //---- toggleButton1 ---- toggleButton1.setText("OK"); - add(toggleButton1, "cell 1 13"); + add(toggleButton1, "cell 1 16"); //---- toggleButton2 ---- toggleButton2.setText("OK"); toggleButton2.setSelected(true); - add(toggleButton2, "cell 2 13"); + add(toggleButton2, "cell 2 16"); //---- label32 ---- label32.setText("Help Button"); label32.setFont(label32.getFont().deriveFont(label32.getFont().getSize() + 4f)); - add(label32, "cell 0 14 2 1"); + add(label32, "cell 0 17 2 1"); //---- label9 ---- - label9.setText("regular"); - add(label9, "cell 1 15"); + label9.setText("unfocused"); + add(label9, "cell 1 18 2 1,alignx center,growx 0"); //---- label33 ---- label33.setText("focused"); - add(label33, "cell 2 15"); + add(label33, "cell 3 18 2 1,alignx center,growx 0"); //---- label22 ---- label22.setText("none"); - add(label22, "cell 0 16"); + add(label22, "cell 0 19"); //---- testStateButton15 ---- testStateButton15.putClientProperty("JComponent.minimumWidth", 0); testStateButton15.putClientProperty("JButton.buttonType", "help"); - add(testStateButton15, "cell 1 16"); + add(testStateButton15, "cell 1 19"); //---- testStateButton19 ---- testStateButton19.setStateFocused(true); testStateButton19.putClientProperty("JComponent.minimumWidth", 0); testStateButton19.putClientProperty("JButton.buttonType", "help"); - add(testStateButton19, "cell 2 16"); + add(testStateButton19, "cell 3 19"); //---- label23 ---- label23.setText("hover"); - add(label23, "cell 0 17"); + add(label23, "cell 0 20"); //---- testStateButton16 ---- testStateButton16.setStateHover(true); testStateButton16.putClientProperty("JComponent.minimumWidth", 0); testStateButton16.putClientProperty("JButton.buttonType", "help"); - add(testStateButton16, "cell 1 17"); + add(testStateButton16, "cell 1 20"); //---- testStateButton20 ---- testStateButton20.setStateHover(true); testStateButton20.setStateFocused(true); testStateButton20.putClientProperty("JComponent.minimumWidth", 0); testStateButton20.putClientProperty("JButton.buttonType", "help"); - add(testStateButton20, "cell 2 17"); + add(testStateButton20, "cell 3 20"); //---- label24 ---- label24.setText("pressed"); - add(label24, "cell 0 18"); + add(label24, "cell 0 21"); //---- testStateButton17 ---- testStateButton17.setStatePressed(true); testStateButton17.putClientProperty("JComponent.minimumWidth", 0); testStateButton17.putClientProperty("JButton.buttonType", "help"); - add(testStateButton17, "cell 1 18"); + add(testStateButton17, "cell 1 21"); //---- testStateButton21 ---- testStateButton21.setStatePressed(true); testStateButton21.setStateFocused(true); testStateButton21.putClientProperty("JComponent.minimumWidth", 0); testStateButton21.putClientProperty("JButton.buttonType", "help"); - add(testStateButton21, "cell 2 18"); + add(testStateButton21, "cell 3 21"); //---- label25 ---- label25.setText("disabled"); - add(label25, "cell 0 19"); + add(label25, "cell 0 22"); //---- testStateButton18 ---- testStateButton18.setEnabled(false); testStateButton18.putClientProperty("JComponent.minimumWidth", 0); testStateButton18.putClientProperty("JButton.buttonType", "help"); - add(testStateButton18, "cell 1 19"); + add(testStateButton18, "cell 1 22"); //---- label26 ---- label26.setText("try me"); - add(label26, "cell 0 20"); + add(label26, "cell 0 23"); //---- button2 ---- button2.putClientProperty("JComponent.minimumWidth", 0); button2.putClientProperty("JButton.buttonType", "help"); - add(button2, "cell 1 20"); + add(button2, "cell 1 23"); + + //---- buttonGroup1 ---- + ButtonGroup buttonGroup1 = new ButtonGroup(); + buttonGroup1.add(noneButton); + buttonGroup1.add(squareButton); + buttonGroup1.add(roundRectButton); + buttonGroup1.add(tabButton); + buttonGroup1.add(toolBarButtonButton); + buttonGroup1.add(borderlessButton); // JFormDesigner - End of component initialization //GEN-END:initComponents } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables - private JLabel label11; - private JLabel label5; - private JLabel label7; - private JLabel label6; - private JLabel label8; - private JLabel label1; - private FlatThemePreviewButtons.TestStateButton testStateButton1; - private FlatThemePreviewButtons.TestStateButton testStateButton7; - private FlatThemePreviewButtons.TestStateButton testStateButton4; - private FlatThemePreviewButtons.TestStateButton testStateButton10; - private JLabel label2; - private FlatThemePreviewButtons.TestStateButton testStateButton2; - private FlatThemePreviewButtons.TestStateButton testStateButton8; - private FlatThemePreviewButtons.TestStateButton testStateButton5; - private FlatThemePreviewButtons.TestStateButton testStateButton11; - private JLabel label3; - private FlatThemePreviewButtons.TestStateButton testStateButton3; - private FlatThemePreviewButtons.TestStateButton testStateButton9; - private FlatThemePreviewButtons.TestStateButton testStateButton6; - private FlatThemePreviewButtons.TestStateButton testStateButton12; - private JLabel label4; - private FlatThemePreviewButtons.TestStateButton testStateButton13; - private FlatThemePreviewButtons.TestStateButton testStateButton14; - private JLabel label10; - private JButton button1; - private FlatThemePreviewButtons.TestDefaultButton testDefaultButton1; - private JLabel label12; - private JLabel label13; - private JLabel label14; - private JLabel label15; - private JLabel label16; - private JLabel label17; - private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton1; - private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton5; - private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton9; - private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton12; - private JLabel label18; - private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton2; - private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton6; - private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton10; - private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton13; - private JLabel label19; - private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton3; - private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton7; - private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton11; - private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton14; - private JLabel label20; - private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton4; - private FlatThemePreviewButtons.TestStateToggleButton testStateToggleButton8; - private JLabel label21; - private JToggleButton toggleButton1; - private JToggleButton toggleButton2; - private JLabel label32; - private JLabel label9; - private JLabel label33; - private JLabel label22; - private FlatThemePreviewButtons.TestStateButton testStateButton15; - private FlatThemePreviewButtons.TestStateButton testStateButton19; - private JLabel label23; - private FlatThemePreviewButtons.TestStateButton testStateButton16; - private FlatThemePreviewButtons.TestStateButton testStateButton20; - private JLabel label24; - private FlatThemePreviewButtons.TestStateButton testStateButton17; - private FlatThemePreviewButtons.TestStateButton testStateButton21; - private JLabel label25; - private FlatThemePreviewButtons.TestStateButton testStateButton18; - private JLabel label26; - private JButton button2; + private JToggleButton noneButton; + private JToggleButton squareButton; + private JToggleButton roundRectButton; + private JToggleButton tabButton; + private JToggleButton toolBarButtonButton; + private JToggleButton borderlessButton; // JFormDesigner - End of variables declaration //GEN-END:variables //---- class TestStateButton ---------------------------------------------- diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.jfd b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.jfd index 8926f247..bfd53d8b 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.jfd +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.jfd @@ -3,55 +3,164 @@ JFDML JFormDesigner: "7.0.4.0.360" Java: "16" encoding: "UTF-8" new FormModel { contentType: "form/swing" root: new FormRoot { + auxiliary() { + "JavaCodeGenerator.defaultVariableLocal": true + } add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets dialog,hidemode 3" "$columnConstraints": "[fill][fill][fill]para[fill][fill]para" - "$rowConstraints": "[][][][][][]unrel[]para[][][][][][]unrel[]para[][][][][][]unrel[]" + "$rowConstraints": "[]para[][]0[][][][][]unrel[]para[][]0[][][][][]unrel[]para[][][][][][]unrel[]" } ) { name: "this" + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "insets 0,hidemode 3" + "$columnConstraints": "[fill][fill]" + "$rowConstraints": "[]0[]" + } ) { + name: "panel1" + add( new FormComponent( "javax.swing.JLabel" ) { + name: "buttonTypeLabel" + "text": "Button type:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { + name: "buttonTypeToolBar1" + "floatable": false + "border": &EmptyBorder0 new javax.swing.border.EmptyBorder( 0, 0, 0, 0 ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "noneButton" + "text": "none" + "$buttonGroup": new FormReference( "buttonGroup1" ) + "selected": true + "font": &SwingDerivedFont0 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "buttonTypeChanged", false ) ) + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "squareButton" + "text": "square" + "$buttonGroup": new FormReference( "buttonGroup1" ) + "font": #SwingDerivedFont0 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "buttonTypeChanged", false ) ) + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "roundRectButton" + "text": "roundRect" + "$buttonGroup": new FormReference( "buttonGroup1" ) + "font": #SwingDerivedFont0 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "buttonTypeChanged", false ) ) + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "tabButton" + "text": "tab" + "$buttonGroup": new FormReference( "buttonGroup1" ) + "font": #SwingDerivedFont0 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "buttonTypeChanged", false ) ) + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 0" + } ) + add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { + name: "buttonTypeToolBar2" + "floatable": false + "border": #EmptyBorder0 + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "toolBarButtonButton" + "text": "toolBarButton" + "$buttonGroup": new FormReference( "buttonGroup1" ) + "font": #SwingDerivedFont0 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "buttonTypeChanged", false ) ) + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "borderlessButton" + "text": "borderless" + "$buttonGroup": new FormReference( "buttonGroup1" ) + "font": #SwingDerivedFont0 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "buttonTypeChanged", false ) ) + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 1" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0 5 1" + } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label11" "text": "JButton" - "font": &SwingDerivedFont0 new com.jformdesigner.model.SwingDerivedFont( null, 0, 4, false ) + "font": &SwingDerivedFont1 new com.jformdesigner.model.SwingDerivedFont( null, 0, 4, false ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 0 3 1" + "value": "cell 0 1 3 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label27" + "text": "unfocused" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 2 2 1,alignx center,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label28" + "text": "focused" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 2 2 1,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label5" "text": "regular" + "font": &SwingDerivedFont2 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 1" + "value": "cell 1 3" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label7" "text": "default" + "font": #SwingDerivedFont2 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 1" + "value": "cell 2 3" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label6" - "text": "focused" + "text": "regular" + "font": #SwingDerivedFont2 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 1" + "value": "cell 3 3" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label8" "text": "default" + "font": #SwingDerivedFont2 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 1" + "value": "cell 4 3" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label1" "text": "none" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 2" + "value": "cell 0 4" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton1" "text": "OK" "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 2" + "value": "cell 1 4" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton7" @@ -59,7 +168,7 @@ new FormModel { "stateDefault": true "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 2" + "value": "cell 2 4" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton4" @@ -67,7 +176,7 @@ new FormModel { "stateFocused": true "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 2" + "value": "cell 3 4" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton10" @@ -76,13 +185,13 @@ new FormModel { "stateDefault": true "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 2" + "value": "cell 4 4" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label2" "text": "hover" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 3" + "value": "cell 0 5" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton2" @@ -90,7 +199,7 @@ new FormModel { "stateHover": true "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" + "value": "cell 1 5" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton8" @@ -99,7 +208,7 @@ new FormModel { "stateDefault": true "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 3" + "value": "cell 2 5" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton5" @@ -108,7 +217,7 @@ new FormModel { "stateFocused": true "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 3" + "value": "cell 3 5" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton11" @@ -118,13 +227,13 @@ new FormModel { "stateDefault": true "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 3" + "value": "cell 4 5" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label3" "text": "pressed" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 4" + "value": "cell 0 6" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton3" @@ -132,7 +241,7 @@ new FormModel { "statePressed": true "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 4" + "value": "cell 1 6" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton9" @@ -141,7 +250,7 @@ new FormModel { "stateDefault": true "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 4" + "value": "cell 2 6" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton6" @@ -150,7 +259,7 @@ new FormModel { "stateFocused": true "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 4" + "value": "cell 3 6" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton12" @@ -160,13 +269,13 @@ new FormModel { "stateDefault": true "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 4" + "value": "cell 4 6" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label4" "text": "disabled" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 5" + "value": "cell 0 7" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton13" @@ -174,7 +283,7 @@ new FormModel { "enabled": false "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 5" + "value": "cell 1 7" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton14" @@ -183,84 +292,100 @@ new FormModel { "stateDefault": true "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 5" + "value": "cell 2 7" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label10" "text": "try me" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 6" + "value": "cell 0 8" } ) add( new FormComponent( "javax.swing.JButton" ) { name: "button1" "text": "OK" "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 6" + "value": "cell 1 8" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestDefaultButton" ) { name: "testDefaultButton1" "text": "OK" "$client.JComponent.minimumWidth": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 6" + "value": "cell 2 8" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label12" "text": "JToggleButton" - "font": #SwingDerivedFont0 + "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 7 3 1" + "value": "cell 0 9 3 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label29" + "text": "unfocused" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 10 2 1,alignx center,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label30" + "text": "focused" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 10 2 1,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label13" "text": "unsel." + "font": #SwingDerivedFont2 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 8" + "value": "cell 1 11" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label14" "text": "selected" + "font": #SwingDerivedFont2 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 8" + "value": "cell 2 11" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label15" - "text": "focused" + "text": "unsel." + "font": #SwingDerivedFont2 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 8" + "value": "cell 3 11" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label16" "text": "selected" + "font": #SwingDerivedFont2 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 8" + "value": "cell 4 11" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label17" "text": "none" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 9" + "value": "cell 0 12" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { name: "testStateToggleButton1" "text": "OK" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 9" + "value": "cell 1 12" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { name: "testStateToggleButton5" "text": "OK" "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 9" + "value": "cell 2 12" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { name: "testStateToggleButton9" "text": "OK" "stateFocused": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 9" + "value": "cell 3 12" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { name: "testStateToggleButton12" @@ -268,20 +393,20 @@ new FormModel { "stateSelected": true "stateFocused": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 9" + "value": "cell 4 12" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label18" "text": "hover" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 10" + "value": "cell 0 13" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { name: "testStateToggleButton2" "text": "OK" "stateHover": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 10" + "value": "cell 1 13" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { name: "testStateToggleButton6" @@ -289,7 +414,7 @@ new FormModel { "stateHover": true "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 10" + "value": "cell 2 13" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { name: "testStateToggleButton10" @@ -297,7 +422,7 @@ new FormModel { "stateHover": true "stateFocused": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 10" + "value": "cell 3 13" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { name: "testStateToggleButton13" @@ -306,20 +431,20 @@ new FormModel { "stateSelected": true "stateFocused": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 10" + "value": "cell 4 13" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label19" "text": "pressed" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 11" + "value": "cell 0 14" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { name: "testStateToggleButton3" "text": "OK" "statePressed": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 11" + "value": "cell 1 14" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { name: "testStateToggleButton7" @@ -327,7 +452,7 @@ new FormModel { "statePressed": true "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 11" + "value": "cell 2 14" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { name: "testStateToggleButton11" @@ -335,7 +460,7 @@ new FormModel { "statePressed": true "stateFocused": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 11" + "value": "cell 3 14" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { name: "testStateToggleButton14" @@ -344,20 +469,20 @@ new FormModel { "stateSelected": true "stateFocused": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 11" + "value": "cell 4 14" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label20" "text": "disabled" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 12" + "value": "cell 0 15" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { name: "testStateToggleButton4" "text": "OK" "enabled": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 12" + "value": "cell 1 15" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateToggleButton" ) { name: "testStateToggleButton8" @@ -365,58 +490,58 @@ new FormModel { "enabled": false "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 12" + "value": "cell 2 15" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label21" "text": "try me" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 13" + "value": "cell 0 16" } ) add( new FormComponent( "javax.swing.JToggleButton" ) { name: "toggleButton1" "text": "OK" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 13" + "value": "cell 1 16" } ) add( new FormComponent( "javax.swing.JToggleButton" ) { name: "toggleButton2" "text": "OK" "selected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 13" + "value": "cell 2 16" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label32" "text": "Help Button" - "font": #SwingDerivedFont0 + "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 14 2 1" + "value": "cell 0 17 2 1" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label9" - "text": "regular" + "text": "unfocused" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 15" + "value": "cell 1 18 2 1,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label33" "text": "focused" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 15" + "value": "cell 3 18 2 1,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label22" "text": "none" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 16" + "value": "cell 0 19" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton15" "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 16" + "value": "cell 1 19" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton19" @@ -424,13 +549,13 @@ new FormModel { "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 16" + "value": "cell 3 19" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label23" "text": "hover" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 17" + "value": "cell 0 20" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton16" @@ -438,7 +563,7 @@ new FormModel { "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 17" + "value": "cell 1 20" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton20" @@ -447,13 +572,13 @@ new FormModel { "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 17" + "value": "cell 3 20" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label24" "text": "pressed" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 18" + "value": "cell 0 21" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton17" @@ -461,7 +586,7 @@ new FormModel { "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 18" + "value": "cell 1 21" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton21" @@ -470,13 +595,13 @@ new FormModel { "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 18" + "value": "cell 3 21" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label25" "text": "disabled" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 19" + "value": "cell 0 22" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton18" @@ -484,24 +609,29 @@ new FormModel { "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 19" + "value": "cell 1 22" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label26" "text": "try me" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 20" + "value": "cell 0 23" } ) add( new FormComponent( "javax.swing.JButton" ) { name: "button2" "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 20" + "value": "cell 1 23" } ) }, new FormLayoutConstraints( null ) { - "location": new java.awt.Point( 0, 0 ) + "location": new java.awt.Point( 5, 0 ) "size": new java.awt.Dimension( 335, 685 ) } ) + add( new FormNonVisual( "javax.swing.ButtonGroup" ) { + name: "buttonGroup1" + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 5, 765 ) + } ) } } diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.java index 4d30fac8..d31f8ece 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.java @@ -33,58 +33,62 @@ class FlatThemePreviewSwitches private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents - label22 = new JLabel(); - label23 = new JLabel(); - label28 = new JLabel(); - label24 = new JLabel(); - label29 = new JLabel(); - label17 = new JLabel(); - testStateCheckBox1 = new FlatThemePreviewSwitches.TestStateCheckBox(); - testStateCheckBox8 = new FlatThemePreviewSwitches.TestStateCheckBox(); - testStateCheckBox5 = new FlatThemePreviewSwitches.TestStateCheckBox(); - testStateCheckBox12 = new FlatThemePreviewSwitches.TestStateCheckBox(); - label18 = new JLabel(); - testStateCheckBox2 = new FlatThemePreviewSwitches.TestStateCheckBox(); - testStateCheckBox9 = new FlatThemePreviewSwitches.TestStateCheckBox(); - testStateCheckBox6 = new FlatThemePreviewSwitches.TestStateCheckBox(); - testStateCheckBox13 = new FlatThemePreviewSwitches.TestStateCheckBox(); - label19 = new JLabel(); - testStateCheckBox3 = new FlatThemePreviewSwitches.TestStateCheckBox(); - testStateCheckBox10 = new FlatThemePreviewSwitches.TestStateCheckBox(); - testStateCheckBox7 = new FlatThemePreviewSwitches.TestStateCheckBox(); - testStateCheckBox14 = new FlatThemePreviewSwitches.TestStateCheckBox(); - label20 = new JLabel(); - testStateCheckBox4 = new FlatThemePreviewSwitches.TestStateCheckBox(); - testStateCheckBox11 = new FlatThemePreviewSwitches.TestStateCheckBox(); - label21 = new JLabel(); - checkBox1 = new JCheckBox(); - checkBox2 = new JCheckBox(); - label27 = new JLabel(); - label25 = new JLabel(); - label30 = new JLabel(); - label26 = new JLabel(); - label31 = new JLabel(); - label36 = new JLabel(); - testStateRadioButton1 = new FlatThemePreviewSwitches.TestStateRadioButton(); - testStateRadioButton8 = new FlatThemePreviewSwitches.TestStateRadioButton(); - testStateRadioButton5 = new FlatThemePreviewSwitches.TestStateRadioButton(); - testStateRadioButton9 = new FlatThemePreviewSwitches.TestStateRadioButton(); - label35 = new JLabel(); - testStateRadioButton2 = new FlatThemePreviewSwitches.TestStateRadioButton(); - testStateRadioButton10 = new FlatThemePreviewSwitches.TestStateRadioButton(); - testStateRadioButton6 = new FlatThemePreviewSwitches.TestStateRadioButton(); - testStateRadioButton11 = new FlatThemePreviewSwitches.TestStateRadioButton(); - label34 = new JLabel(); - testStateRadioButton3 = new FlatThemePreviewSwitches.TestStateRadioButton(); - testStateRadioButton12 = new FlatThemePreviewSwitches.TestStateRadioButton(); - testStateRadioButton7 = new FlatThemePreviewSwitches.TestStateRadioButton(); - testStateRadioButton13 = new FlatThemePreviewSwitches.TestStateRadioButton(); - label33 = new JLabel(); - testStateRadioButton4 = new FlatThemePreviewSwitches.TestStateRadioButton(); - testStateRadioButton14 = new FlatThemePreviewSwitches.TestStateRadioButton(); - label32 = new JLabel(); - radioButton1 = new JRadioButton(); - radioButton2 = new JRadioButton(); + JLabel label22 = new JLabel(); + JLabel label1 = new JLabel(); + JLabel label2 = new JLabel(); + JLabel label23 = new JLabel(); + JLabel label28 = new JLabel(); + JLabel label24 = new JLabel(); + JLabel label29 = new JLabel(); + JLabel label17 = new JLabel(); + FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox1 = new FlatThemePreviewSwitches.TestStateCheckBox(); + FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox8 = new FlatThemePreviewSwitches.TestStateCheckBox(); + FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox5 = new FlatThemePreviewSwitches.TestStateCheckBox(); + FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox12 = new FlatThemePreviewSwitches.TestStateCheckBox(); + JLabel label18 = new JLabel(); + FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox2 = new FlatThemePreviewSwitches.TestStateCheckBox(); + FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox9 = new FlatThemePreviewSwitches.TestStateCheckBox(); + FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox6 = new FlatThemePreviewSwitches.TestStateCheckBox(); + FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox13 = new FlatThemePreviewSwitches.TestStateCheckBox(); + JLabel label19 = new JLabel(); + FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox3 = new FlatThemePreviewSwitches.TestStateCheckBox(); + FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox10 = new FlatThemePreviewSwitches.TestStateCheckBox(); + FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox7 = new FlatThemePreviewSwitches.TestStateCheckBox(); + FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox14 = new FlatThemePreviewSwitches.TestStateCheckBox(); + JLabel label20 = new JLabel(); + FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox4 = new FlatThemePreviewSwitches.TestStateCheckBox(); + FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox11 = new FlatThemePreviewSwitches.TestStateCheckBox(); + JLabel label21 = new JLabel(); + JCheckBox checkBox1 = new JCheckBox(); + JCheckBox checkBox2 = new JCheckBox(); + JLabel label27 = new JLabel(); + JLabel label3 = new JLabel(); + JLabel label4 = new JLabel(); + JLabel label25 = new JLabel(); + JLabel label30 = new JLabel(); + JLabel label26 = new JLabel(); + JLabel label31 = new JLabel(); + JLabel label36 = new JLabel(); + FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton1 = new FlatThemePreviewSwitches.TestStateRadioButton(); + FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton8 = new FlatThemePreviewSwitches.TestStateRadioButton(); + FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton5 = new FlatThemePreviewSwitches.TestStateRadioButton(); + FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton9 = new FlatThemePreviewSwitches.TestStateRadioButton(); + JLabel label35 = new JLabel(); + FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton2 = new FlatThemePreviewSwitches.TestStateRadioButton(); + FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton10 = new FlatThemePreviewSwitches.TestStateRadioButton(); + FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton6 = new FlatThemePreviewSwitches.TestStateRadioButton(); + FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton11 = new FlatThemePreviewSwitches.TestStateRadioButton(); + JLabel label34 = new JLabel(); + FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton3 = new FlatThemePreviewSwitches.TestStateRadioButton(); + FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton12 = new FlatThemePreviewSwitches.TestStateRadioButton(); + FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton7 = new FlatThemePreviewSwitches.TestStateRadioButton(); + FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton13 = new FlatThemePreviewSwitches.TestStateRadioButton(); + JLabel label33 = new JLabel(); + FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton4 = new FlatThemePreviewSwitches.TestStateRadioButton(); + FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton14 = new FlatThemePreviewSwitches.TestStateRadioButton(); + JLabel label32 = new JLabel(); + JRadioButton radioButton1 = new JRadioButton(); + JRadioButton radioButton2 = new JRadioButton(); //======== this ======== setLayout(new MigLayout( @@ -97,6 +101,7 @@ class FlatThemePreviewSwitches "[fill]para", // rows "[]" + + "[]0" + "[]" + "[]" + "[]" + @@ -104,6 +109,7 @@ class FlatThemePreviewSwitches "[]unrel" + "[]para" + "[]" + + "[]0" + "[]" + "[]" + "[]" + @@ -116,314 +122,286 @@ class FlatThemePreviewSwitches label22.setFont(label22.getFont().deriveFont(label22.getFont().getSize() + 4f)); add(label22, "cell 0 0 3 1"); + //---- label1 ---- + label1.setText("unfocused"); + add(label1, "cell 1 1 2 1,alignx center,growx 0"); + + //---- label2 ---- + label2.setText("focused"); + add(label2, "cell 3 1 2 1,alignx center,growx 0"); + //---- label23 ---- label23.setText("unsel."); - add(label23, "cell 1 1"); + label23.setFont(label23.getFont().deriveFont(label23.getFont().getSize() - 2f)); + add(label23, "cell 1 2"); //---- label28 ---- label28.setText("selected"); - add(label28, "cell 2 1"); + label28.setFont(label28.getFont().deriveFont(label28.getFont().getSize() - 2f)); + add(label28, "cell 2 2"); //---- label24 ---- - label24.setText("focused"); - add(label24, "cell 3 1"); + label24.setText("unsel."); + label24.setFont(label24.getFont().deriveFont(label24.getFont().getSize() - 2f)); + add(label24, "cell 3 2"); //---- label29 ---- label29.setText("selected"); - add(label29, "cell 4 1"); + label29.setFont(label29.getFont().deriveFont(label29.getFont().getSize() - 2f)); + add(label29, "cell 4 2"); //---- label17 ---- label17.setText("none"); - add(label17, "cell 0 2"); + add(label17, "cell 0 3"); //---- testStateCheckBox1 ---- testStateCheckBox1.setText("text"); - add(testStateCheckBox1, "cell 1 2"); + add(testStateCheckBox1, "cell 1 3"); //---- testStateCheckBox8 ---- testStateCheckBox8.setText("text"); testStateCheckBox8.setStateSelected(true); - add(testStateCheckBox8, "cell 2 2"); + add(testStateCheckBox8, "cell 2 3"); //---- testStateCheckBox5 ---- testStateCheckBox5.setText("text"); testStateCheckBox5.setStateFocused(true); - add(testStateCheckBox5, "cell 3 2"); + add(testStateCheckBox5, "cell 3 3"); //---- testStateCheckBox12 ---- testStateCheckBox12.setText("text"); testStateCheckBox12.setStateFocused(true); testStateCheckBox12.setStateSelected(true); - add(testStateCheckBox12, "cell 4 2"); + add(testStateCheckBox12, "cell 4 3"); //---- label18 ---- label18.setText("hover"); - add(label18, "cell 0 3"); + add(label18, "cell 0 4"); //---- testStateCheckBox2 ---- testStateCheckBox2.setText("text"); testStateCheckBox2.setStateHover(true); - add(testStateCheckBox2, "cell 1 3"); + add(testStateCheckBox2, "cell 1 4"); //---- testStateCheckBox9 ---- testStateCheckBox9.setText("text"); testStateCheckBox9.setStateHover(true); testStateCheckBox9.setStateSelected(true); - add(testStateCheckBox9, "cell 2 3"); + add(testStateCheckBox9, "cell 2 4"); //---- testStateCheckBox6 ---- testStateCheckBox6.setText("text"); testStateCheckBox6.setStateFocused(true); testStateCheckBox6.setStateHover(true); - add(testStateCheckBox6, "cell 3 3"); + add(testStateCheckBox6, "cell 3 4"); //---- testStateCheckBox13 ---- testStateCheckBox13.setText("text"); testStateCheckBox13.setStateFocused(true); testStateCheckBox13.setStateHover(true); testStateCheckBox13.setStateSelected(true); - add(testStateCheckBox13, "cell 4 3"); + add(testStateCheckBox13, "cell 4 4"); //---- label19 ---- label19.setText("pressed"); - add(label19, "cell 0 4"); + add(label19, "cell 0 5"); //---- testStateCheckBox3 ---- testStateCheckBox3.setText("text"); testStateCheckBox3.setStatePressed(true); - add(testStateCheckBox3, "cell 1 4"); + add(testStateCheckBox3, "cell 1 5"); //---- testStateCheckBox10 ---- testStateCheckBox10.setText("text"); testStateCheckBox10.setStatePressed(true); testStateCheckBox10.setStateSelected(true); - add(testStateCheckBox10, "cell 2 4"); + add(testStateCheckBox10, "cell 2 5"); //---- testStateCheckBox7 ---- testStateCheckBox7.setText("text"); testStateCheckBox7.setStateFocused(true); testStateCheckBox7.setStatePressed(true); - add(testStateCheckBox7, "cell 3 4"); + add(testStateCheckBox7, "cell 3 5"); //---- testStateCheckBox14 ---- testStateCheckBox14.setText("text"); testStateCheckBox14.setStateFocused(true); testStateCheckBox14.setStatePressed(true); testStateCheckBox14.setStateSelected(true); - add(testStateCheckBox14, "cell 4 4"); + add(testStateCheckBox14, "cell 4 5"); //---- label20 ---- label20.setText("disabled"); - add(label20, "cell 0 5"); + add(label20, "cell 0 6"); //---- testStateCheckBox4 ---- testStateCheckBox4.setText("text"); testStateCheckBox4.setEnabled(false); - add(testStateCheckBox4, "cell 1 5"); + add(testStateCheckBox4, "cell 1 6"); //---- testStateCheckBox11 ---- testStateCheckBox11.setText("text"); testStateCheckBox11.setEnabled(false); testStateCheckBox11.setStateSelected(true); - add(testStateCheckBox11, "cell 2 5"); + add(testStateCheckBox11, "cell 2 6"); //---- label21 ---- label21.setText("try me"); - add(label21, "cell 0 6"); + add(label21, "cell 0 7"); //---- checkBox1 ---- checkBox1.setText("text"); - add(checkBox1, "cell 1 6"); + add(checkBox1, "cell 1 7"); //---- checkBox2 ---- checkBox2.setText("text"); checkBox2.setSelected(true); - add(checkBox2, "cell 2 6"); + add(checkBox2, "cell 2 7"); //---- label27 ---- label27.setText("JRadioButton"); label27.setFont(label27.getFont().deriveFont(label27.getFont().getSize() + 4f)); - add(label27, "cell 0 7 3 1"); + add(label27, "cell 0 8 3 1"); + + //---- label3 ---- + label3.setText("unfocused"); + add(label3, "cell 1 9 2 1,alignx center,growx 0"); + + //---- label4 ---- + label4.setText("focused"); + add(label4, "cell 3 9 2 1,alignx center,growx 0"); //---- label25 ---- label25.setText("unsel."); - add(label25, "cell 1 8"); + label25.setFont(label25.getFont().deriveFont(label25.getFont().getSize() - 2f)); + add(label25, "cell 1 10"); //---- label30 ---- label30.setText("selected"); - add(label30, "cell 2 8"); + label30.setFont(label30.getFont().deriveFont(label30.getFont().getSize() - 2f)); + add(label30, "cell 2 10"); //---- label26 ---- - label26.setText("focused"); - add(label26, "cell 3 8"); + label26.setText("unsel."); + label26.setFont(label26.getFont().deriveFont(label26.getFont().getSize() - 2f)); + add(label26, "cell 3 10"); //---- label31 ---- label31.setText("selected"); - add(label31, "cell 4 8"); + label31.setFont(label31.getFont().deriveFont(label31.getFont().getSize() - 2f)); + add(label31, "cell 4 10"); //---- label36 ---- label36.setText("none"); - add(label36, "cell 0 9"); + add(label36, "cell 0 11"); //---- testStateRadioButton1 ---- testStateRadioButton1.setText("text"); - add(testStateRadioButton1, "cell 1 9"); + add(testStateRadioButton1, "cell 1 11"); //---- testStateRadioButton8 ---- testStateRadioButton8.setText("text"); testStateRadioButton8.setStateSelected(true); - add(testStateRadioButton8, "cell 2 9"); + add(testStateRadioButton8, "cell 2 11"); //---- testStateRadioButton5 ---- testStateRadioButton5.setText("text"); testStateRadioButton5.setStateFocused(true); - add(testStateRadioButton5, "cell 3 9"); + add(testStateRadioButton5, "cell 3 11"); //---- testStateRadioButton9 ---- testStateRadioButton9.setText("text"); testStateRadioButton9.setStateFocused(true); testStateRadioButton9.setStateSelected(true); - add(testStateRadioButton9, "cell 4 9"); + add(testStateRadioButton9, "cell 4 11"); //---- label35 ---- label35.setText("hover"); - add(label35, "cell 0 10"); + add(label35, "cell 0 12"); //---- testStateRadioButton2 ---- testStateRadioButton2.setText("text"); testStateRadioButton2.setStateHover(true); - add(testStateRadioButton2, "cell 1 10"); + add(testStateRadioButton2, "cell 1 12"); //---- testStateRadioButton10 ---- testStateRadioButton10.setText("text"); testStateRadioButton10.setStateHover(true); testStateRadioButton10.setStateSelected(true); - add(testStateRadioButton10, "cell 2 10"); + add(testStateRadioButton10, "cell 2 12"); //---- testStateRadioButton6 ---- testStateRadioButton6.setText("text"); testStateRadioButton6.setStateFocused(true); testStateRadioButton6.setStateHover(true); - add(testStateRadioButton6, "cell 3 10"); + add(testStateRadioButton6, "cell 3 12"); //---- testStateRadioButton11 ---- testStateRadioButton11.setText("text"); testStateRadioButton11.setStateFocused(true); testStateRadioButton11.setStateHover(true); testStateRadioButton11.setStateSelected(true); - add(testStateRadioButton11, "cell 4 10"); + add(testStateRadioButton11, "cell 4 12"); //---- label34 ---- label34.setText("pressed"); - add(label34, "cell 0 11"); + add(label34, "cell 0 13"); //---- testStateRadioButton3 ---- testStateRadioButton3.setText("text"); testStateRadioButton3.setStatePressed(true); - add(testStateRadioButton3, "cell 1 11"); + add(testStateRadioButton3, "cell 1 13"); //---- testStateRadioButton12 ---- testStateRadioButton12.setText("text"); testStateRadioButton12.setStatePressed(true); testStateRadioButton12.setStateSelected(true); - add(testStateRadioButton12, "cell 2 11"); + add(testStateRadioButton12, "cell 2 13"); //---- testStateRadioButton7 ---- testStateRadioButton7.setText("text"); testStateRadioButton7.setStateFocused(true); testStateRadioButton7.setStatePressed(true); - add(testStateRadioButton7, "cell 3 11"); + add(testStateRadioButton7, "cell 3 13"); //---- testStateRadioButton13 ---- testStateRadioButton13.setText("text"); testStateRadioButton13.setStateFocused(true); testStateRadioButton13.setStatePressed(true); testStateRadioButton13.setStateSelected(true); - add(testStateRadioButton13, "cell 4 11"); + add(testStateRadioButton13, "cell 4 13"); //---- label33 ---- label33.setText("disabled"); - add(label33, "cell 0 12"); + add(label33, "cell 0 14"); //---- testStateRadioButton4 ---- testStateRadioButton4.setText("text"); testStateRadioButton4.setEnabled(false); - add(testStateRadioButton4, "cell 1 12"); + add(testStateRadioButton4, "cell 1 14"); //---- testStateRadioButton14 ---- testStateRadioButton14.setText("text"); testStateRadioButton14.setEnabled(false); testStateRadioButton14.setStateSelected(true); - add(testStateRadioButton14, "cell 2 12"); + add(testStateRadioButton14, "cell 2 14"); //---- label32 ---- label32.setText("try me"); - add(label32, "cell 0 13"); + add(label32, "cell 0 15"); //---- radioButton1 ---- radioButton1.setText("text"); - add(radioButton1, "cell 1 13"); + add(radioButton1, "cell 1 15"); //---- radioButton2 ---- radioButton2.setText("text"); radioButton2.setSelected(true); - add(radioButton2, "cell 2 13"); + add(radioButton2, "cell 2 15"); // JFormDesigner - End of component initialization //GEN-END:initComponents } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables - private JLabel label22; - private JLabel label23; - private JLabel label28; - private JLabel label24; - private JLabel label29; - private JLabel label17; - private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox1; - private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox8; - private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox5; - private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox12; - private JLabel label18; - private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox2; - private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox9; - private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox6; - private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox13; - private JLabel label19; - private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox3; - private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox10; - private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox7; - private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox14; - private JLabel label20; - private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox4; - private FlatThemePreviewSwitches.TestStateCheckBox testStateCheckBox11; - private JLabel label21; - private JCheckBox checkBox1; - private JCheckBox checkBox2; - private JLabel label27; - private JLabel label25; - private JLabel label30; - private JLabel label26; - private JLabel label31; - private JLabel label36; - private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton1; - private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton8; - private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton5; - private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton9; - private JLabel label35; - private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton2; - private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton10; - private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton6; - private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton11; - private JLabel label34; - private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton3; - private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton12; - private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton7; - private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton13; - private JLabel label33; - private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton4; - private FlatThemePreviewSwitches.TestStateRadioButton testStateRadioButton14; - private JLabel label32; - private JRadioButton radioButton1; - private JRadioButton radioButton2; // JFormDesigner - End of variables declaration //GEN-END:variables //---- class TestStateCheckBox -------------------------------------------- diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.jfd b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.jfd index 819e9be7..7851d64d 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.jfd +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.jfd @@ -3,10 +3,13 @@ JFDML JFormDesigner: "7.0.4.0.360" Java: "16" encoding: "UTF-8" new FormModel { contentType: "form/swing" root: new FormRoot { + auxiliary() { + "JavaCodeGenerator.defaultVariableLocal": true + } add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets dialog,hidemode 3" "$columnConstraints": "[fill][fill][fill]para[fill][fill]para" - "$rowConstraints": "[][][][][][]unrel[]para[][][][][][]unrel[]" + "$rowConstraints": "[][]0[][][][][]unrel[]para[][]0[][][][][]unrel[]" } ) { name: "this" add( new FormComponent( "javax.swing.JLabel" ) { @@ -16,55 +19,71 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 0 3 1" } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label1" + "text": "unfocused" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 1 2 1,alignx center,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label2" + "text": "focused" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 1 2 1,alignx center,growx 0" + } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label23" "text": "unsel." + "font": &SwingDerivedFont1 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 1" + "value": "cell 1 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label28" "text": "selected" + "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 1" + "value": "cell 2 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label24" - "text": "focused" + "text": "unsel." + "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 1" + "value": "cell 3 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label29" "text": "selected" + "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 1" + "value": "cell 4 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label17" "text": "none" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 2" + "value": "cell 0 3" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { name: "testStateCheckBox1" "text": "text" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 2" + "value": "cell 1 3" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { name: "testStateCheckBox8" "text": "text" "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 2" + "value": "cell 2 3" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { name: "testStateCheckBox5" "text": "text" "stateFocused": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 2" + "value": "cell 3 3" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { name: "testStateCheckBox12" @@ -72,20 +91,20 @@ new FormModel { "stateFocused": true "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 2" + "value": "cell 4 3" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label18" "text": "hover" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 3" + "value": "cell 0 4" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { name: "testStateCheckBox2" "text": "text" "stateHover": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" + "value": "cell 1 4" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { name: "testStateCheckBox9" @@ -93,7 +112,7 @@ new FormModel { "stateHover": true "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 3" + "value": "cell 2 4" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { name: "testStateCheckBox6" @@ -101,7 +120,7 @@ new FormModel { "stateFocused": true "stateHover": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 3" + "value": "cell 3 4" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { name: "testStateCheckBox13" @@ -110,20 +129,20 @@ new FormModel { "stateHover": true "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 3" + "value": "cell 4 4" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label19" "text": "pressed" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 4" + "value": "cell 0 5" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { name: "testStateCheckBox3" "text": "text" "statePressed": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 4" + "value": "cell 1 5" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { name: "testStateCheckBox10" @@ -131,7 +150,7 @@ new FormModel { "statePressed": true "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 4" + "value": "cell 2 5" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { name: "testStateCheckBox7" @@ -139,7 +158,7 @@ new FormModel { "stateFocused": true "statePressed": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 4" + "value": "cell 3 5" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { name: "testStateCheckBox14" @@ -148,20 +167,20 @@ new FormModel { "statePressed": true "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 4" + "value": "cell 4 5" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label20" "text": "disabled" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 5" + "value": "cell 0 6" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { name: "testStateCheckBox4" "text": "text" "enabled": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 5" + "value": "cell 1 6" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateCheckBox" ) { name: "testStateCheckBox11" @@ -169,83 +188,99 @@ new FormModel { "enabled": false "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 5" + "value": "cell 2 6" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label21" "text": "try me" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 6" + "value": "cell 0 7" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "checkBox1" "text": "text" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 6" + "value": "cell 1 7" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "checkBox2" "text": "text" "selected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 6" + "value": "cell 2 7" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label27" "text": "JRadioButton" "font": #SwingDerivedFont0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 7 3 1" + "value": "cell 0 8 3 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label3" + "text": "unfocused" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 9 2 1,alignx center,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label4" + "text": "focused" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 9 2 1,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label25" "text": "unsel." + "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 8" + "value": "cell 1 10" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label30" "text": "selected" + "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 8" + "value": "cell 2 10" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label26" - "text": "focused" + "text": "unsel." + "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 8" + "value": "cell 3 10" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label31" "text": "selected" + "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 8" + "value": "cell 4 10" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label36" "text": "none" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 9" + "value": "cell 0 11" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { name: "testStateRadioButton1" "text": "text" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 9" + "value": "cell 1 11" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { name: "testStateRadioButton8" "text": "text" "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 9" + "value": "cell 2 11" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { name: "testStateRadioButton5" "text": "text" "stateFocused": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 9" + "value": "cell 3 11" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { name: "testStateRadioButton9" @@ -253,20 +288,20 @@ new FormModel { "stateFocused": true "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 9" + "value": "cell 4 11" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label35" "text": "hover" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 10" + "value": "cell 0 12" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { name: "testStateRadioButton2" "text": "text" "stateHover": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 10" + "value": "cell 1 12" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { name: "testStateRadioButton10" @@ -274,7 +309,7 @@ new FormModel { "stateHover": true "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 10" + "value": "cell 2 12" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { name: "testStateRadioButton6" @@ -282,7 +317,7 @@ new FormModel { "stateFocused": true "stateHover": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 10" + "value": "cell 3 12" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { name: "testStateRadioButton11" @@ -291,20 +326,20 @@ new FormModel { "stateHover": true "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 10" + "value": "cell 4 12" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label34" "text": "pressed" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 11" + "value": "cell 0 13" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { name: "testStateRadioButton3" "text": "text" "statePressed": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 11" + "value": "cell 1 13" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { name: "testStateRadioButton12" @@ -312,7 +347,7 @@ new FormModel { "statePressed": true "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 11" + "value": "cell 2 13" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { name: "testStateRadioButton7" @@ -320,7 +355,7 @@ new FormModel { "stateFocused": true "statePressed": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 11" + "value": "cell 3 13" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { name: "testStateRadioButton13" @@ -329,20 +364,20 @@ new FormModel { "statePressed": true "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 11" + "value": "cell 4 13" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label33" "text": "disabled" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 12" + "value": "cell 0 14" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { name: "testStateRadioButton4" "text": "text" "enabled": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 12" + "value": "cell 1 14" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewSwitches$TestStateRadioButton" ) { name: "testStateRadioButton14" @@ -350,26 +385,26 @@ new FormModel { "enabled": false "stateSelected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 12" + "value": "cell 2 14" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label32" "text": "try me" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 13" + "value": "cell 0 15" } ) add( new FormComponent( "javax.swing.JRadioButton" ) { name: "radioButton1" "text": "text" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 13" + "value": "cell 1 15" } ) add( new FormComponent( "javax.swing.JRadioButton" ) { name: "radioButton2" "text": "text" "selected": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 13" + "value": "cell 2 15" } ) }, new FormLayoutConstraints( null ) { "location": new java.awt.Point( 0, 0 ) From 0b6247851bafd466b2a0d1ff19241f3dde527098 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 5 Sep 2021 22:05:21 +0200 Subject: [PATCH 12/13] Theme Editor: fixed preview of focused list and table selection --- .../com/formdev/flatlaf/ui/FlatListUI.java | 13 +++++++++++ .../com/formdev/flatlaf/ui/FlatTableUI.java | 23 +++++++++++++++++++ .../themeeditor/FlatThemePreviewAll.java | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java index d639ecb3..5c1fe585 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java @@ -20,10 +20,12 @@ import java.awt.Color; import java.awt.EventQueue; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; +import java.beans.PropertyChangeListener; import javax.swing.JComponent; import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicListUI; +import com.formdev.flatlaf.FlatClientProperties; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JList}. @@ -95,6 +97,17 @@ public class FlatListUI selectionInactiveForeground = null; } + @Override + protected PropertyChangeListener createPropertyChangeListener() { + PropertyChangeListener superListener = super.createPropertyChangeListener(); + return e -> { + superListener.propertyChange( e ); + + if( FlatClientProperties.COMPONENT_FOCUS_OWNER.equals( e.getPropertyName() ) ) + toggleSelectionColors(); + }; + } + @Override protected FocusListener createFocusListener() { return new BasicListUI.FocusHandler() { diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java index 15aafe1a..d869194e 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java @@ -25,6 +25,7 @@ import java.awt.Graphics2D; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.geom.Rectangle2D; +import java.beans.PropertyChangeListener; import javax.swing.JComponent; import javax.swing.JScrollPane; import javax.swing.JViewport; @@ -34,6 +35,7 @@ import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicTableUI; import javax.swing.table.JTableHeader; +import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.util.Graphics2DProxy; import com.formdev.flatlaf.util.SystemInfo; import com.formdev.flatlaf.util.UIScale; @@ -103,6 +105,8 @@ public class FlatTableUI private boolean oldShowVerticalLines; private Dimension oldIntercellSpacing; + private PropertyChangeListener propertyChangeListener; + public static ComponentUI createUI( JComponent c ) { return new FlatTableUI(); } @@ -162,6 +166,25 @@ public class FlatTableUI table.setIntercellSpacing( oldIntercellSpacing ); } + @Override + protected void installListeners() { + super.installListeners(); + + propertyChangeListener = e -> { + if( FlatClientProperties.COMPONENT_FOCUS_OWNER.equals( e.getPropertyName() ) ) + toggleSelectionColors(); + }; + table.addPropertyChangeListener( propertyChangeListener ); + } + + @Override + protected void uninstallListeners() { + super.uninstallListeners(); + + table.removePropertyChangeListener( propertyChangeListener ); + propertyChangeListener = null; + } + @Override protected FocusListener createFocusListener() { return new BasicTableUI.FocusHandler() { diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java index 4f651072..9f6c2542 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java @@ -59,9 +59,9 @@ class FlatThemePreviewAll list1.setSelectedIndex( 1 ); tree1.setSelectionRow( 1 ); - table1.setRowSelectionInterval( 1, 1 ); table1.setRowSorter( new TableRowSorter<>( table1.getModel() ) ); table1.getRowSorter().toggleSortOrder( 0 ); + table1.setRowSelectionInterval( 1, 1 ); table1.uiDefaultsGetter = preview::getUIDefaultProperty; EventQueue.invokeLater( () -> { From 6018f83a22e03f9a053c5e47bb7743ffb8b49c64 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 5 Sep 2021 22:15:49 +0200 Subject: [PATCH 13/13] Theme Editor: center some labels and help buttons in preview --- .../themeeditor/FlatThemePreviewButtons.java | 32 +++++++++---------- .../themeeditor/FlatThemePreviewButtons.jfd | 32 +++++++++---------- .../themeeditor/FlatThemePreviewSwitches.java | 16 +++++----- .../themeeditor/FlatThemePreviewSwitches.jfd | 16 +++++----- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.java index d79e9592..4771bda9 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.java @@ -260,22 +260,22 @@ class FlatThemePreviewButtons //---- label5 ---- label5.setText("regular"); label5.setFont(label5.getFont().deriveFont(label5.getFont().getSize() - 2f)); - add(label5, "cell 1 3"); + add(label5, "cell 1 3,alignx center,growx 0"); //---- label7 ---- label7.setText("default"); label7.setFont(label7.getFont().deriveFont(label7.getFont().getSize() - 2f)); - add(label7, "cell 2 3"); + add(label7, "cell 2 3,alignx center,growx 0"); //---- label6 ---- label6.setText("regular"); label6.setFont(label6.getFont().deriveFont(label6.getFont().getSize() - 2f)); - add(label6, "cell 3 3"); + add(label6, "cell 3 3,alignx center,growx 0"); //---- label8 ---- label8.setText("default"); label8.setFont(label8.getFont().deriveFont(label8.getFont().getSize() - 2f)); - add(label8, "cell 4 3"); + add(label8, "cell 4 3,alignx center,growx 0"); //---- label1 ---- label1.setText("none"); @@ -416,22 +416,22 @@ class FlatThemePreviewButtons //---- label13 ---- label13.setText("unsel."); label13.setFont(label13.getFont().deriveFont(label13.getFont().getSize() - 2f)); - add(label13, "cell 1 11"); + add(label13, "cell 1 11,alignx center,growx 0"); //---- label14 ---- label14.setText("selected"); label14.setFont(label14.getFont().deriveFont(label14.getFont().getSize() - 2f)); - add(label14, "cell 2 11"); + add(label14, "cell 2 11,alignx center,growx 0"); //---- label15 ---- label15.setText("unsel."); label15.setFont(label15.getFont().deriveFont(label15.getFont().getSize() - 2f)); - add(label15, "cell 3 11"); + add(label15, "cell 3 11,alignx center,growx 0"); //---- label16 ---- label16.setText("selected"); label16.setFont(label16.getFont().deriveFont(label16.getFont().getSize() - 2f)); - add(label16, "cell 4 11"); + add(label16, "cell 4 11,alignx center,growx 0"); //---- label17 ---- label17.setText("none"); @@ -561,13 +561,13 @@ class FlatThemePreviewButtons //---- testStateButton15 ---- testStateButton15.putClientProperty("JComponent.minimumWidth", 0); testStateButton15.putClientProperty("JButton.buttonType", "help"); - add(testStateButton15, "cell 1 19"); + add(testStateButton15, "cell 1 19 2 1,alignx center,growx 0"); //---- testStateButton19 ---- testStateButton19.setStateFocused(true); testStateButton19.putClientProperty("JComponent.minimumWidth", 0); testStateButton19.putClientProperty("JButton.buttonType", "help"); - add(testStateButton19, "cell 3 19"); + add(testStateButton19, "cell 3 19 2 1,alignx center,growx 0"); //---- label23 ---- label23.setText("hover"); @@ -577,14 +577,14 @@ class FlatThemePreviewButtons testStateButton16.setStateHover(true); testStateButton16.putClientProperty("JComponent.minimumWidth", 0); testStateButton16.putClientProperty("JButton.buttonType", "help"); - add(testStateButton16, "cell 1 20"); + add(testStateButton16, "cell 1 20 2 1,alignx center,growx 0"); //---- testStateButton20 ---- testStateButton20.setStateHover(true); testStateButton20.setStateFocused(true); testStateButton20.putClientProperty("JComponent.minimumWidth", 0); testStateButton20.putClientProperty("JButton.buttonType", "help"); - add(testStateButton20, "cell 3 20"); + add(testStateButton20, "cell 3 20 2 1,alignx center,growx 0"); //---- label24 ---- label24.setText("pressed"); @@ -594,14 +594,14 @@ class FlatThemePreviewButtons testStateButton17.setStatePressed(true); testStateButton17.putClientProperty("JComponent.minimumWidth", 0); testStateButton17.putClientProperty("JButton.buttonType", "help"); - add(testStateButton17, "cell 1 21"); + add(testStateButton17, "cell 1 21 2 1,alignx center,growx 0"); //---- testStateButton21 ---- testStateButton21.setStatePressed(true); testStateButton21.setStateFocused(true); testStateButton21.putClientProperty("JComponent.minimumWidth", 0); testStateButton21.putClientProperty("JButton.buttonType", "help"); - add(testStateButton21, "cell 3 21"); + add(testStateButton21, "cell 3 21 2 1,alignx center,growx 0"); //---- label25 ---- label25.setText("disabled"); @@ -611,7 +611,7 @@ class FlatThemePreviewButtons testStateButton18.setEnabled(false); testStateButton18.putClientProperty("JComponent.minimumWidth", 0); testStateButton18.putClientProperty("JButton.buttonType", "help"); - add(testStateButton18, "cell 1 22"); + add(testStateButton18, "cell 1 22 2 1,alignx center,growx 0"); //---- label26 ---- label26.setText("try me"); @@ -620,7 +620,7 @@ class FlatThemePreviewButtons //---- button2 ---- button2.putClientProperty("JComponent.minimumWidth", 0); button2.putClientProperty("JButton.buttonType", "help"); - add(button2, "cell 1 23"); + add(button2, "cell 1 23 2 1,alignx center,growx 0"); //---- buttonGroup1 ---- ButtonGroup buttonGroup1 = new ButtonGroup(); diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.jfd b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.jfd index bfd53d8b..b4cb937d 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.jfd +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.jfd @@ -126,28 +126,28 @@ new FormModel { "text": "regular" "font": &SwingDerivedFont2 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" + "value": "cell 1 3,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label7" "text": "default" "font": #SwingDerivedFont2 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 3" + "value": "cell 2 3,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label6" "text": "regular" "font": #SwingDerivedFont2 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 3" + "value": "cell 3 3,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label8" "text": "default" "font": #SwingDerivedFont2 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 3" + "value": "cell 4 3,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label1" @@ -338,28 +338,28 @@ new FormModel { "text": "unsel." "font": #SwingDerivedFont2 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 11" + "value": "cell 1 11,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label14" "text": "selected" "font": #SwingDerivedFont2 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 11" + "value": "cell 2 11,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label15" "text": "unsel." "font": #SwingDerivedFont2 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 11" + "value": "cell 3 11,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label16" "text": "selected" "font": #SwingDerivedFont2 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 11" + "value": "cell 4 11,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label17" @@ -541,7 +541,7 @@ new FormModel { "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 19" + "value": "cell 1 19 2 1,alignx center,growx 0" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton19" @@ -549,7 +549,7 @@ new FormModel { "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 19" + "value": "cell 3 19 2 1,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label23" @@ -563,7 +563,7 @@ new FormModel { "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 20" + "value": "cell 1 20 2 1,alignx center,growx 0" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton20" @@ -572,7 +572,7 @@ new FormModel { "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 20" + "value": "cell 3 20 2 1,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label24" @@ -586,7 +586,7 @@ new FormModel { "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 21" + "value": "cell 1 21 2 1,alignx center,growx 0" } ) add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewButtons$TestStateButton" ) { name: "testStateButton21" @@ -595,7 +595,7 @@ new FormModel { "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 21" + "value": "cell 3 21 2 1,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label25" @@ -609,7 +609,7 @@ new FormModel { "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 22" + "value": "cell 1 22 2 1,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label26" @@ -622,7 +622,7 @@ new FormModel { "$client.JComponent.minimumWidth": 0 "$client.JButton.buttonType": "help" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 23" + "value": "cell 1 23 2 1,alignx center,growx 0" } ) }, new FormLayoutConstraints( null ) { "location": new java.awt.Point( 5, 0 ) diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.java index d31f8ece..775c7122 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.java @@ -133,22 +133,22 @@ class FlatThemePreviewSwitches //---- label23 ---- label23.setText("unsel."); label23.setFont(label23.getFont().deriveFont(label23.getFont().getSize() - 2f)); - add(label23, "cell 1 2"); + add(label23, "cell 1 2,alignx center,growx 0"); //---- label28 ---- label28.setText("selected"); label28.setFont(label28.getFont().deriveFont(label28.getFont().getSize() - 2f)); - add(label28, "cell 2 2"); + add(label28, "cell 2 2,alignx center,growx 0"); //---- label24 ---- label24.setText("unsel."); label24.setFont(label24.getFont().deriveFont(label24.getFont().getSize() - 2f)); - add(label24, "cell 3 2"); + add(label24, "cell 3 2,alignx center,growx 0"); //---- label29 ---- label29.setText("selected"); label29.setFont(label29.getFont().deriveFont(label29.getFont().getSize() - 2f)); - add(label29, "cell 4 2"); + add(label29, "cell 4 2,alignx center,growx 0"); //---- label17 ---- label17.setText("none"); @@ -274,22 +274,22 @@ class FlatThemePreviewSwitches //---- label25 ---- label25.setText("unsel."); label25.setFont(label25.getFont().deriveFont(label25.getFont().getSize() - 2f)); - add(label25, "cell 1 10"); + add(label25, "cell 1 10,alignx center,growx 0"); //---- label30 ---- label30.setText("selected"); label30.setFont(label30.getFont().deriveFont(label30.getFont().getSize() - 2f)); - add(label30, "cell 2 10"); + add(label30, "cell 2 10,alignx center,growx 0"); //---- label26 ---- label26.setText("unsel."); label26.setFont(label26.getFont().deriveFont(label26.getFont().getSize() - 2f)); - add(label26, "cell 3 10"); + add(label26, "cell 3 10,alignx center,growx 0"); //---- label31 ---- label31.setText("selected"); label31.setFont(label31.getFont().deriveFont(label31.getFont().getSize() - 2f)); - add(label31, "cell 4 10"); + add(label31, "cell 4 10,alignx center,growx 0"); //---- label36 ---- label36.setText("none"); diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.jfd b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.jfd index 7851d64d..502633e0 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.jfd +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.jfd @@ -36,28 +36,28 @@ new FormModel { "text": "unsel." "font": &SwingDerivedFont1 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 2" + "value": "cell 1 2,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label28" "text": "selected" "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 2" + "value": "cell 2 2,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label24" "text": "unsel." "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 2" + "value": "cell 3 2,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label29" "text": "selected" "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 2" + "value": "cell 4 2,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label17" @@ -233,28 +233,28 @@ new FormModel { "text": "unsel." "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 10" + "value": "cell 1 10,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label30" "text": "selected" "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 10" + "value": "cell 2 10,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label26" "text": "unsel." "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 10" + "value": "cell 3 10,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label31" "text": "selected" "font": #SwingDerivedFont1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 10" + "value": "cell 4 10,alignx center,growx 0" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label36"