diff --git a/CHANGELOG.md b/CHANGELOG.md index e4c7d432..5c7e1ae7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,13 @@ 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) +- 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. ## 1.5 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 998e7429..31e6e66a 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 @@ -48,6 +48,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/FlatListUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java index 2135ef28..de0c02d0 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 @@ -27,6 +27,7 @@ import javax.swing.JComponent; import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicListUI; +import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; @@ -140,8 +141,22 @@ public class FlatListUI @Override protected PropertyChangeListener createPropertyChangeListener() { - return FlatStylingSupport.createPropertyChangeListener( list, this::applyStyle, - super.createPropertyChangeListener() ); + PropertyChangeListener superListener = super.createPropertyChangeListener(); + return e -> { + superListener.propertyChange( e ); + + switch( e.getPropertyName() ) { + case FlatClientProperties.COMPONENT_FOCUS_OWNER: + toggleSelectionColors(); + break; + + case FlatClientProperties.STYLE: + applyStyle( e.getNewValue() ); + list.revalidate(); + list.repaint(); + break; + } + }; } /** 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 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 ab8d163f..150566e8 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 * * * 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 2237d6fb..f47dd5e3 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 @@ -45,6 +45,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" ) ); @@ -137,6 +138,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 770323f5..ff60f80e 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.beans.PropertyChangeListener; import java.util.Map; @@ -32,6 +35,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; @@ -62,6 +66,7 @@ import com.formdev.flatlaf.util.UIScale; * @uiDefault TableHeader.cellMargins Insets * @uiDefault TableHeader.separatorColor Color * @uiDefault TableHeader.bottomSeparatorColor Color + * @uiDefault TableHeader.showLastVerticalLine boolean * * * @@ -173,6 +178,11 @@ public class FlatTableHeaderUI } } + @Override + protected MouseInputListener createMouseInputListener() { + return new FlatMouseInputHandler(); + } + // overridden and made public to allow usage in custom renderers @Override public int getRolloverColumn() { @@ -331,4 +341,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() ); + } + } + } + } + } } 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 d8577b89..b36e159b 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 @@ -75,6 +75,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 @@ -97,6 +98,7 @@ public class FlatTableUI { protected boolean showHorizontalLines; protected boolean showVerticalLines; + protected boolean showLastVerticalLine; protected Dimension intercellSpacing; @Styleable protected Color selectionBackground; @@ -133,6 +135,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" ); @@ -187,15 +190,27 @@ public class FlatTableUI protected void installListeners() { super.installListeners(); - propertyChangeListener = FlatStylingSupport.createPropertyChangeListener( table, this::applyStyle, null ); - table.addPropertyChangeListener( FlatClientProperties.STYLE, propertyChangeListener ); + propertyChangeListener = e -> { + switch( e.getPropertyName() ) { + case FlatClientProperties.COMPONENT_FOCUS_OWNER: + toggleSelectionColors(); + break; + + case FlatClientProperties.STYLE: + applyStyle( e.getNewValue() ); + table.revalidate(); + table.repaint(); + break; + } + }; + table.addPropertyChangeListener( propertyChangeListener ); } @Override protected void uninstallListeners() { super.uninstallListeners(); - table.removePropertyChangeListener( FlatClientProperties.STYLE, propertyChangeListener ); + table.removePropertyChangeListener( propertyChangeListener ); propertyChangeListener = null; } @@ -377,6 +392,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/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java index d739ee5a..197c1810 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 @@ -342,12 +342,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 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-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; 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-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-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 -> { 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/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(); 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..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 @@ -18,25 +18,17 @@ 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 java.util.prefs.Preferences; 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 @@ -45,47 +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(); - 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 - } - } ); + // 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() ); @@ -97,10 +69,31 @@ class FlatThemePreview // update when showing preview (e.g. activating tab) addHierarchyListener( e -> { if( (e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 && isShowing() ) + selectRecentTab(); updateLater(); } ); } + 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; + } + + 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(); @@ -128,13 +121,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 +144,7 @@ class FlatThemePreview } } - private Object getUIDefaultProperty( Object key ) { + Object getUIDefaultProperty( Object key ) { if( !(key instanceof String) ) return null; @@ -178,919 +176,132 @@ 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); + } + 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..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 @@ -3,640 +3,32 @@ 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 + }, 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..9f6c2542 --- /dev/null +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java @@ -0,0 +1,857 @@ +/* +/* + * 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 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; +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.setRowSorter( new TableRowSorter<>( table1.getModel() ) ); + table1.getRowSorter().toggleSortOrder( 0 ); + table1.setRowSelectionInterval( 1, 1 ); + 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() { + boolean enabled = enabledCheckBox.isSelected(); + + // disable "focused" checkbox because disabled components are not focusable + focusedCheckBox.setEnabled( enabled ); + if( focusedCheckBox.isSelected() ) + focusedChanged(); + + preview.runWithUIDefaultsGetter( () -> { + enableDisable( this, enabled ); + } ); + } + + private void enableDisable( Component comp, boolean enabled ) { + if( comp != enabledCheckBox && comp != focusedCheckBox && 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 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 ); + 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(); + 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(); + 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(); + 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(); + JLabel progressBarLabel = new JLabel(); + progressBar1 = new FlatProgressBar(); + progressBar2 = new FlatProgressBar(); + JLabel toolTipLabel = new JLabel(); + JToolTip toolTip1 = new JToolTip(); + JLabel toolBarLabel = new JLabel(); + toolBar1 = new JToolBar(); + JButton button4 = new JButton(); + JButton button6 = new JButton(); + JToggleButton button7 = new JToggleButton(); + JToggleButton button8 = new JToggleButton(); + JLabel tabbedPaneLabel = new JLabel(); + tabbedPane1 = new FlatThemePreviewAll.PreviewTabbedPane(); + JLabel listTreeLabel = new JLabel(); + JSplitPane splitPane1 = new JSplitPane(); + JScrollPane scrollPane2 = new JScrollPane(); + list1 = new JList<>(); + JScrollPane scrollPane3 = new JScrollPane(); + tree1 = new JTree(); + JLabel tableLabel = new JLabel(); + JScrollPane scrollPane4 = new JScrollPane(); + table1 = new FlatThemePreviewAll.PreviewTable(); + JLabel 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"); + + //---- focusedCheckBox ---- + focusedCheckBox.setText("Focused"); + focusedCheckBox.addActionListener(e -> focusedChanged()); + add(focusedCheckBox, "cell 0 0 2 1"); + + //---- 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 JCheckBox focusedCheckBox; + private FlatTextField textField1; + private JMenu menu2; + private JSlider slider1; + private JSlider slider3; + private FlatProgressBar progressBar1; + private FlatProgressBar progressBar2; + private JToolBar toolBar1; + private FlatThemePreviewAll.PreviewTabbedPane tabbedPane1; + private JList list1; + private JTree tree1; + private FlatThemePreviewAll.PreviewTable table1; + 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..34b3de15 --- /dev/null +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.jfd @@ -0,0 +1,673 @@ +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]" + "$rowConstraints": "[]unrel[][][][][][][][][][][][][][][][][][][][][][][][][100,fill][grow]" + } ) { + name: "this" + add( new FormComponent( "javax.swing.JCheckBox" ) { + 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:" + }, 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" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + 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 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + }, 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 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + }, 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" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + 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" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + }, 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" ) + } + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + } ) + }, 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" + } ) + } ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + } ) + }, 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 ) + } ) + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + } ) + }, 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" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + 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 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + }, 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" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + }, 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..4771bda9 --- /dev/null +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.java @@ -0,0 +1,786 @@ +/* + * 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.Component; +import java.util.Objects; +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 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 + 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( + "insets dialog,hidemode 3", + // columns + "[fill]" + + "[fill]" + + "[fill]para" + + "[fill]" + + "[fill]para", + // rows + "[]para" + + "[]" + + "[]0" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]unrel" + + "[]para" + + "[]" + + "[]0" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]unrel" + + "[]para" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]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 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"); + label5.setFont(label5.getFont().deriveFont(label5.getFont().getSize() - 2f)); + 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,alignx center,growx 0"); + + //---- label6 ---- + label6.setText("regular"); + label6.setFont(label6.getFont().deriveFont(label6.getFont().getSize() - 2f)); + 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,alignx center,growx 0"); + + //---- label1 ---- + label1.setText("none"); + add(label1, "cell 0 4"); + + //---- testStateButton1 ---- + testStateButton1.setText("OK"); + testStateButton1.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton1, "cell 1 4"); + + //---- testStateButton7 ---- + testStateButton7.setText("OK"); + testStateButton7.setStateDefault(true); + testStateButton7.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton7, "cell 2 4"); + + //---- testStateButton4 ---- + testStateButton4.setText("OK"); + testStateButton4.setStateFocused(true); + testStateButton4.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton4, "cell 3 4"); + + //---- testStateButton10 ---- + testStateButton10.setText("OK"); + testStateButton10.setStateFocused(true); + testStateButton10.setStateDefault(true); + testStateButton10.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton10, "cell 4 4"); + + //---- label2 ---- + label2.setText("hover"); + add(label2, "cell 0 5"); + + //---- testStateButton2 ---- + testStateButton2.setText("OK"); + testStateButton2.setStateHover(true); + testStateButton2.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton2, "cell 1 5"); + + //---- testStateButton8 ---- + testStateButton8.setText("OK"); + testStateButton8.setStateHover(true); + testStateButton8.setStateDefault(true); + testStateButton8.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton8, "cell 2 5"); + + //---- testStateButton5 ---- + testStateButton5.setText("OK"); + testStateButton5.setStateHover(true); + testStateButton5.setStateFocused(true); + testStateButton5.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton5, "cell 3 5"); + + //---- testStateButton11 ---- + testStateButton11.setText("OK"); + testStateButton11.setStateHover(true); + testStateButton11.setStateFocused(true); + testStateButton11.setStateDefault(true); + testStateButton11.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton11, "cell 4 5"); + + //---- label3 ---- + label3.setText("pressed"); + add(label3, "cell 0 6"); + + //---- testStateButton3 ---- + testStateButton3.setText("OK"); + testStateButton3.setStatePressed(true); + testStateButton3.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton3, "cell 1 6"); + + //---- testStateButton9 ---- + testStateButton9.setText("OK"); + testStateButton9.setStatePressed(true); + testStateButton9.setStateDefault(true); + testStateButton9.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton9, "cell 2 6"); + + //---- testStateButton6 ---- + testStateButton6.setText("OK"); + testStateButton6.setStatePressed(true); + testStateButton6.setStateFocused(true); + testStateButton6.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton6, "cell 3 6"); + + //---- testStateButton12 ---- + testStateButton12.setText("OK"); + testStateButton12.setStatePressed(true); + testStateButton12.setStateFocused(true); + testStateButton12.setStateDefault(true); + testStateButton12.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton12, "cell 4 6"); + + //---- label4 ---- + label4.setText("disabled"); + add(label4, "cell 0 7"); + + //---- testStateButton13 ---- + testStateButton13.setText("OK"); + testStateButton13.setEnabled(false); + testStateButton13.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton13, "cell 1 7"); + + //---- testStateButton14 ---- + testStateButton14.setText("OK"); + testStateButton14.setEnabled(false); + testStateButton14.setStateDefault(true); + testStateButton14.putClientProperty("JComponent.minimumWidth", 0); + add(testStateButton14, "cell 2 7"); + + //---- label10 ---- + label10.setText("try me"); + add(label10, "cell 0 8"); + + //---- button1 ---- + button1.setText("OK"); + button1.putClientProperty("JComponent.minimumWidth", 0); + add(button1, "cell 1 8"); + + //---- testDefaultButton1 ---- + testDefaultButton1.setText("OK"); + testDefaultButton1.putClientProperty("JComponent.minimumWidth", 0); + add(testDefaultButton1, "cell 2 8"); + + //---- label12 ---- + label12.setText("JToggleButton"); + label12.setFont(label12.getFont().deriveFont(label12.getFont().getSize() + 4f)); + 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."); + label13.setFont(label13.getFont().deriveFont(label13.getFont().getSize() - 2f)); + 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,alignx center,growx 0"); + + //---- label15 ---- + label15.setText("unsel."); + label15.setFont(label15.getFont().deriveFont(label15.getFont().getSize() - 2f)); + 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,alignx center,growx 0"); + + //---- label17 ---- + label17.setText("none"); + add(label17, "cell 0 12"); + + //---- testStateToggleButton1 ---- + testStateToggleButton1.setText("OK"); + add(testStateToggleButton1, "cell 1 12"); + + //---- testStateToggleButton5 ---- + testStateToggleButton5.setText("OK"); + testStateToggleButton5.setStateSelected(true); + add(testStateToggleButton5, "cell 2 12"); + + //---- testStateToggleButton9 ---- + testStateToggleButton9.setText("OK"); + testStateToggleButton9.setStateFocused(true); + add(testStateToggleButton9, "cell 3 12"); + + //---- testStateToggleButton12 ---- + testStateToggleButton12.setText("OK"); + testStateToggleButton12.setStateSelected(true); + testStateToggleButton12.setStateFocused(true); + add(testStateToggleButton12, "cell 4 12"); + + //---- label18 ---- + label18.setText("hover"); + add(label18, "cell 0 13"); + + //---- testStateToggleButton2 ---- + testStateToggleButton2.setText("OK"); + testStateToggleButton2.setStateHover(true); + add(testStateToggleButton2, "cell 1 13"); + + //---- testStateToggleButton6 ---- + testStateToggleButton6.setText("OK"); + testStateToggleButton6.setStateHover(true); + testStateToggleButton6.setStateSelected(true); + add(testStateToggleButton6, "cell 2 13"); + + //---- testStateToggleButton10 ---- + testStateToggleButton10.setText("OK"); + testStateToggleButton10.setStateHover(true); + testStateToggleButton10.setStateFocused(true); + add(testStateToggleButton10, "cell 3 13"); + + //---- testStateToggleButton13 ---- + testStateToggleButton13.setText("OK"); + testStateToggleButton13.setStateHover(true); + testStateToggleButton13.setStateSelected(true); + testStateToggleButton13.setStateFocused(true); + add(testStateToggleButton13, "cell 4 13"); + + //---- label19 ---- + label19.setText("pressed"); + add(label19, "cell 0 14"); + + //---- testStateToggleButton3 ---- + testStateToggleButton3.setText("OK"); + testStateToggleButton3.setStatePressed(true); + add(testStateToggleButton3, "cell 1 14"); + + //---- testStateToggleButton7 ---- + testStateToggleButton7.setText("OK"); + testStateToggleButton7.setStatePressed(true); + testStateToggleButton7.setStateSelected(true); + add(testStateToggleButton7, "cell 2 14"); + + //---- testStateToggleButton11 ---- + testStateToggleButton11.setText("OK"); + testStateToggleButton11.setStatePressed(true); + testStateToggleButton11.setStateFocused(true); + add(testStateToggleButton11, "cell 3 14"); + + //---- testStateToggleButton14 ---- + testStateToggleButton14.setText("OK"); + testStateToggleButton14.setStatePressed(true); + testStateToggleButton14.setStateSelected(true); + testStateToggleButton14.setStateFocused(true); + add(testStateToggleButton14, "cell 4 14"); + + //---- label20 ---- + label20.setText("disabled"); + add(label20, "cell 0 15"); + + //---- testStateToggleButton4 ---- + testStateToggleButton4.setText("OK"); + testStateToggleButton4.setEnabled(false); + add(testStateToggleButton4, "cell 1 15"); + + //---- testStateToggleButton8 ---- + testStateToggleButton8.setText("OK"); + testStateToggleButton8.setEnabled(false); + testStateToggleButton8.setStateSelected(true); + add(testStateToggleButton8, "cell 2 15"); + + //---- label21 ---- + label21.setText("try me"); + add(label21, "cell 0 16"); + + //---- toggleButton1 ---- + toggleButton1.setText("OK"); + add(toggleButton1, "cell 1 16"); + + //---- toggleButton2 ---- + toggleButton2.setText("OK"); + toggleButton2.setSelected(true); + add(toggleButton2, "cell 2 16"); + + //---- label32 ---- + label32.setText("Help Button"); + label32.setFont(label32.getFont().deriveFont(label32.getFont().getSize() + 4f)); + add(label32, "cell 0 17 2 1"); + + //---- label9 ---- + label9.setText("unfocused"); + add(label9, "cell 1 18 2 1,alignx center,growx 0"); + + //---- label33 ---- + label33.setText("focused"); + add(label33, "cell 3 18 2 1,alignx center,growx 0"); + + //---- label22 ---- + label22.setText("none"); + add(label22, "cell 0 19"); + + //---- testStateButton15 ---- + testStateButton15.putClientProperty("JComponent.minimumWidth", 0); + testStateButton15.putClientProperty("JButton.buttonType", "help"); + 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 2 1,alignx center,growx 0"); + + //---- label23 ---- + label23.setText("hover"); + add(label23, "cell 0 20"); + + //---- testStateButton16 ---- + testStateButton16.setStateHover(true); + testStateButton16.putClientProperty("JComponent.minimumWidth", 0); + testStateButton16.putClientProperty("JButton.buttonType", "help"); + 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 2 1,alignx center,growx 0"); + + //---- label24 ---- + label24.setText("pressed"); + add(label24, "cell 0 21"); + + //---- testStateButton17 ---- + testStateButton17.setStatePressed(true); + testStateButton17.putClientProperty("JComponent.minimumWidth", 0); + testStateButton17.putClientProperty("JButton.buttonType", "help"); + 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 2 1,alignx center,growx 0"); + + //---- label25 ---- + label25.setText("disabled"); + add(label25, "cell 0 22"); + + //---- testStateButton18 ---- + testStateButton18.setEnabled(false); + testStateButton18.putClientProperty("JComponent.minimumWidth", 0); + testStateButton18.putClientProperty("JButton.buttonType", "help"); + add(testStateButton18, "cell 1 22 2 1,alignx center,growx 0"); + + //---- label26 ---- + label26.setText("try me"); + add(label26, "cell 0 23"); + + //---- button2 ---- + button2.putClientProperty("JComponent.minimumWidth", 0); + button2.putClientProperty("JButton.buttonType", "help"); + add(button2, "cell 1 23 2 1,alignx center,growx 0"); + + //---- 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 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 ---------------------------------------------- + + 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..b4cb937d --- /dev/null +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewButtons.jfd @@ -0,0 +1,637 @@ +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": "[]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": &SwingDerivedFont1 new com.jformdesigner.model.SwingDerivedFont( null, 0, 4, false ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 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,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,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,alignx center,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label1" + "text": "none" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 4" + } ) + 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 4" + } ) + 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 4" + } ) + 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 4" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label2" + "text": "hover" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 5" + } ) + 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 5" + } ) + 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 5" + } ) + 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 5" + } ) + 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 5" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label3" + "text": "pressed" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 6" + } ) + 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 6" + } ) + 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 6" + } ) + 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 6" + } ) + 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 6" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label4" + "text": "disabled" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 7" + } ) + 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 7" + } ) + 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 7" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label10" + "text": "try me" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 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 8" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label12" + "text": "JToggleButton" + "font": #SwingDerivedFont1 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 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,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,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,alignx center,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label17" + "text": "none" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 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 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 12" + } ) + 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 12" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label18" + "text": "hover" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 13" + } ) + 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 13" + } ) + 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 13" + } ) + 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 13" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label19" + "text": "pressed" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 14" + } ) + 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 14" + } ) + 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 14" + } ) + 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 14" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label20" + "text": "disabled" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 15" + } ) + 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 15" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label21" + "text": "try me" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 16" + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "toggleButton1" + "text": "OK" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 16" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label32" + "text": "Help Button" + "font": #SwingDerivedFont1 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 17 2 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label9" + "text": "unfocused" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 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 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 19 2 1,alignx center,growx 0" + } ) + 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 3 19 2 1,alignx center,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label23" + "text": "hover" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 20" + } ) + 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 20 2 1,alignx center,growx 0" + } ) + 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 3 20 2 1,alignx center,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label24" + "text": "pressed" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 21" + } ) + 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 21 2 1,alignx center,growx 0" + } ) + 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 3 21 2 1,alignx center,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label25" + "text": "disabled" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 22" + } ) + 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 22 2 1,alignx center,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label26" + "text": "try me" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 23 2 1,alignx center,growx 0" + } ) + }, new FormLayoutConstraints( null ) { + "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 new file mode 100644 index 00000000..775c7122 --- /dev/null +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.java @@ -0,0 +1,536 @@ +/* + * 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 + 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( + "insets dialog,hidemode 3", + // columns + "[fill]" + + "[fill]" + + "[fill]para" + + "[fill]" + + "[fill]para", + // rows + "[]" + + "[]0" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]unrel" + + "[]para" + + "[]" + + "[]0" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]unrel" + + "[]")); + + //---- label22 ---- + label22.setText("JCheckBox"); + 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."); + label23.setFont(label23.getFont().deriveFont(label23.getFont().getSize() - 2f)); + 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,alignx center,growx 0"); + + //---- label24 ---- + label24.setText("unsel."); + label24.setFont(label24.getFont().deriveFont(label24.getFont().getSize() - 2f)); + 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,alignx center,growx 0"); + + //---- label17 ---- + label17.setText("none"); + add(label17, "cell 0 3"); + + //---- testStateCheckBox1 ---- + testStateCheckBox1.setText("text"); + add(testStateCheckBox1, "cell 1 3"); + + //---- testStateCheckBox8 ---- + testStateCheckBox8.setText("text"); + testStateCheckBox8.setStateSelected(true); + add(testStateCheckBox8, "cell 2 3"); + + //---- testStateCheckBox5 ---- + testStateCheckBox5.setText("text"); + testStateCheckBox5.setStateFocused(true); + add(testStateCheckBox5, "cell 3 3"); + + //---- testStateCheckBox12 ---- + testStateCheckBox12.setText("text"); + testStateCheckBox12.setStateFocused(true); + testStateCheckBox12.setStateSelected(true); + add(testStateCheckBox12, "cell 4 3"); + + //---- label18 ---- + label18.setText("hover"); + add(label18, "cell 0 4"); + + //---- testStateCheckBox2 ---- + testStateCheckBox2.setText("text"); + testStateCheckBox2.setStateHover(true); + add(testStateCheckBox2, "cell 1 4"); + + //---- testStateCheckBox9 ---- + testStateCheckBox9.setText("text"); + testStateCheckBox9.setStateHover(true); + testStateCheckBox9.setStateSelected(true); + add(testStateCheckBox9, "cell 2 4"); + + //---- testStateCheckBox6 ---- + testStateCheckBox6.setText("text"); + testStateCheckBox6.setStateFocused(true); + testStateCheckBox6.setStateHover(true); + add(testStateCheckBox6, "cell 3 4"); + + //---- testStateCheckBox13 ---- + testStateCheckBox13.setText("text"); + testStateCheckBox13.setStateFocused(true); + testStateCheckBox13.setStateHover(true); + testStateCheckBox13.setStateSelected(true); + add(testStateCheckBox13, "cell 4 4"); + + //---- label19 ---- + label19.setText("pressed"); + add(label19, "cell 0 5"); + + //---- testStateCheckBox3 ---- + testStateCheckBox3.setText("text"); + testStateCheckBox3.setStatePressed(true); + add(testStateCheckBox3, "cell 1 5"); + + //---- testStateCheckBox10 ---- + testStateCheckBox10.setText("text"); + testStateCheckBox10.setStatePressed(true); + testStateCheckBox10.setStateSelected(true); + add(testStateCheckBox10, "cell 2 5"); + + //---- testStateCheckBox7 ---- + testStateCheckBox7.setText("text"); + testStateCheckBox7.setStateFocused(true); + testStateCheckBox7.setStatePressed(true); + add(testStateCheckBox7, "cell 3 5"); + + //---- testStateCheckBox14 ---- + testStateCheckBox14.setText("text"); + testStateCheckBox14.setStateFocused(true); + testStateCheckBox14.setStatePressed(true); + testStateCheckBox14.setStateSelected(true); + add(testStateCheckBox14, "cell 4 5"); + + //---- label20 ---- + label20.setText("disabled"); + add(label20, "cell 0 6"); + + //---- testStateCheckBox4 ---- + testStateCheckBox4.setText("text"); + testStateCheckBox4.setEnabled(false); + add(testStateCheckBox4, "cell 1 6"); + + //---- testStateCheckBox11 ---- + testStateCheckBox11.setText("text"); + testStateCheckBox11.setEnabled(false); + testStateCheckBox11.setStateSelected(true); + add(testStateCheckBox11, "cell 2 6"); + + //---- label21 ---- + label21.setText("try me"); + add(label21, "cell 0 7"); + + //---- checkBox1 ---- + checkBox1.setText("text"); + add(checkBox1, "cell 1 7"); + + //---- checkBox2 ---- + checkBox2.setText("text"); + checkBox2.setSelected(true); + add(checkBox2, "cell 2 7"); + + //---- label27 ---- + label27.setText("JRadioButton"); + label27.setFont(label27.getFont().deriveFont(label27.getFont().getSize() + 4f)); + 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."); + label25.setFont(label25.getFont().deriveFont(label25.getFont().getSize() - 2f)); + 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,alignx center,growx 0"); + + //---- label26 ---- + label26.setText("unsel."); + label26.setFont(label26.getFont().deriveFont(label26.getFont().getSize() - 2f)); + 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,alignx center,growx 0"); + + //---- label36 ---- + label36.setText("none"); + add(label36, "cell 0 11"); + + //---- testStateRadioButton1 ---- + testStateRadioButton1.setText("text"); + add(testStateRadioButton1, "cell 1 11"); + + //---- testStateRadioButton8 ---- + testStateRadioButton8.setText("text"); + testStateRadioButton8.setStateSelected(true); + add(testStateRadioButton8, "cell 2 11"); + + //---- testStateRadioButton5 ---- + testStateRadioButton5.setText("text"); + testStateRadioButton5.setStateFocused(true); + add(testStateRadioButton5, "cell 3 11"); + + //---- testStateRadioButton9 ---- + testStateRadioButton9.setText("text"); + testStateRadioButton9.setStateFocused(true); + testStateRadioButton9.setStateSelected(true); + add(testStateRadioButton9, "cell 4 11"); + + //---- label35 ---- + label35.setText("hover"); + add(label35, "cell 0 12"); + + //---- testStateRadioButton2 ---- + testStateRadioButton2.setText("text"); + testStateRadioButton2.setStateHover(true); + add(testStateRadioButton2, "cell 1 12"); + + //---- testStateRadioButton10 ---- + testStateRadioButton10.setText("text"); + testStateRadioButton10.setStateHover(true); + testStateRadioButton10.setStateSelected(true); + add(testStateRadioButton10, "cell 2 12"); + + //---- testStateRadioButton6 ---- + testStateRadioButton6.setText("text"); + testStateRadioButton6.setStateFocused(true); + testStateRadioButton6.setStateHover(true); + add(testStateRadioButton6, "cell 3 12"); + + //---- testStateRadioButton11 ---- + testStateRadioButton11.setText("text"); + testStateRadioButton11.setStateFocused(true); + testStateRadioButton11.setStateHover(true); + testStateRadioButton11.setStateSelected(true); + add(testStateRadioButton11, "cell 4 12"); + + //---- label34 ---- + label34.setText("pressed"); + add(label34, "cell 0 13"); + + //---- testStateRadioButton3 ---- + testStateRadioButton3.setText("text"); + testStateRadioButton3.setStatePressed(true); + add(testStateRadioButton3, "cell 1 13"); + + //---- testStateRadioButton12 ---- + testStateRadioButton12.setText("text"); + testStateRadioButton12.setStatePressed(true); + testStateRadioButton12.setStateSelected(true); + add(testStateRadioButton12, "cell 2 13"); + + //---- testStateRadioButton7 ---- + testStateRadioButton7.setText("text"); + testStateRadioButton7.setStateFocused(true); + testStateRadioButton7.setStatePressed(true); + add(testStateRadioButton7, "cell 3 13"); + + //---- testStateRadioButton13 ---- + testStateRadioButton13.setText("text"); + testStateRadioButton13.setStateFocused(true); + testStateRadioButton13.setStatePressed(true); + testStateRadioButton13.setStateSelected(true); + add(testStateRadioButton13, "cell 4 13"); + + //---- label33 ---- + label33.setText("disabled"); + add(label33, "cell 0 14"); + + //---- testStateRadioButton4 ---- + testStateRadioButton4.setText("text"); + testStateRadioButton4.setEnabled(false); + add(testStateRadioButton4, "cell 1 14"); + + //---- testStateRadioButton14 ---- + testStateRadioButton14.setText("text"); + testStateRadioButton14.setEnabled(false); + testStateRadioButton14.setStateSelected(true); + add(testStateRadioButton14, "cell 2 14"); + + //---- label32 ---- + label32.setText("try me"); + add(label32, "cell 0 15"); + + //---- radioButton1 ---- + radioButton1.setText("text"); + add(radioButton1, "cell 1 15"); + + //---- radioButton2 ---- + radioButton2.setText("text"); + radioButton2.setSelected(true); + add(radioButton2, "cell 2 15"); + // JFormDesigner - End of component initialization //GEN-END:initComponents + } + + // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables + // 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..502633e0 --- /dev/null +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewSwitches.jfd @@ -0,0 +1,414 @@ +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": "[][]0[][][][][]unrel[]para[][]0[][][][][]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: "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 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,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,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,alignx center,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label17" + "text": "none" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 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 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 3" + } ) + 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 3" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label18" + "text": "hover" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 4" + } ) + 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 4" + } ) + 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 4" + } ) + 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 4" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label19" + "text": "pressed" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 5" + } ) + 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 5" + } ) + 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 5" + } ) + 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 5" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label20" + "text": "disabled" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 6" + } ) + 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 6" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label21" + "text": "try me" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 7" + } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "checkBox1" + "text": "text" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 7" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label27" + "text": "JRadioButton" + "font": #SwingDerivedFont0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 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,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,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,alignx center,growx 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label36" + "text": "none" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 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 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 11" + } ) + 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 11" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label35" + "text": "hover" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 12" + } ) + 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 12" + } ) + 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 12" + } ) + 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 12" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label34" + "text": "pressed" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 13" + } ) + 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 13" + } ) + 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 13" + } ) + 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 13" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label33" + "text": "disabled" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 14" + } ) + 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 14" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label32" + "text": "try me" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 15" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "radioButton1" + "text": "text" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "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 15" + } ) + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 0 ) + "size": new java.awt.Dimension( 325, 685 ) + } ) + } +} 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