From a5575894ab45e46fd4efed09b84aca5760ba74ce Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 22 Aug 2021 14:26:18 +0200 Subject: [PATCH] Theme Editor: - update preview after 300ms (was 500ms) - added separator between editor and preview --- .../flatlaf/themeeditor/FlatThemePreview.java | 14 +++++++++----- .../flatlaf/themeeditor/FlatThemePreview.jfd | 6 ++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.java index 6d995019..719cfc0b 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 @@ -58,7 +58,7 @@ class FlatThemePreview tabbedPane1.addTab( "Tab 8", null ); // timer used for delayed preview updates - timer = new Timer( 500, e -> update() ); + timer = new Timer( 300, e -> update() ); timer.setRepeats( false ); // listen to changes in text area to automatically update preview @@ -201,15 +201,13 @@ class FlatThemePreview } private void enableDisable( Component comp, boolean enabled ) { - comp.setEnabled( enabled ); + if( comp != previewLabel && comp != enabledCheckBox ) + comp.setEnabled( enabled ); if( !(comp instanceof Container) ) return; for( Component c : ((Container)comp).getComponents() ) { - if( c == enabledCheckBox || c == previewLabel ) - continue; - if( c instanceof JScrollPane ) c = ((JScrollPane)c).getViewport().getView(); @@ -224,6 +222,7 @@ class FlatThemePreview private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents + previewSeparator = new JSeparator(); previewLabel = new JLabel(); enabledCheckBox = new JCheckBox(); separator2 = new JSeparator(); @@ -332,6 +331,10 @@ class FlatThemePreview "[]" + "[grow]")); + //---- previewSeparator ---- + previewSeparator.setOrientation(SwingConstants.VERTICAL); + add(previewSeparator, "west"); + //---- previewLabel ---- previewLabel.setText("Preview"); previewLabel.setFont(previewLabel.getFont().deriveFont(previewLabel.getFont().getSize() + 6f)); @@ -690,6 +693,7 @@ class FlatThemePreview } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables + private JSeparator previewSeparator; private JLabel previewLabel; private JCheckBox enabledCheckBox; private JSeparator separator2; 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 5a8c48ec..ee2bb6ac 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.jfd +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.jfd @@ -9,6 +9,12 @@ new FormModel { "$rowConstraints": "[]0[]unrel[][][][][][][][][][][][][][][][][][][][][][][grow]" } ) { name: "this" + 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"