diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java index 3aea1c87..8c4f08a9 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.java @@ -686,12 +686,14 @@ class FlatThemePreviewAll //---- scrollBar1 ---- scrollBar1.setOrientation(Adjustable.HORIZONTAL); scrollBar1.putClientProperty("FlatLaf.styleClass", "flatlaf-preview-scrollbar"); + scrollBar1.setVisibleAmount(50); add(scrollBar1, "cell 1 12 2 1"); //---- scrollBar5 ---- scrollBar5.setOrientation(Adjustable.HORIZONTAL); scrollBar5.setShowButtons(true); scrollBar5.putClientProperty("FlatLaf.styleClass", "flatlaf-preview-scrollbar"); + scrollBar5.setVisibleAmount(50); add(scrollBar5, "cell 1 13 2 1"); //---- separatorLabel ---- @@ -707,7 +709,6 @@ class FlatThemePreviewAll add(sliderLabel, "cell 0 15"); //---- slider1 ---- - slider1.setValue(30); slider1.putClientProperty("FlatLaf.styleClass", "flatlaf-preview-slider"); add(slider1, "cell 1 15 2 1,width 100"); @@ -716,7 +717,6 @@ class FlatThemePreviewAll slider3.setPaintTicks(true); slider3.setMajorTickSpacing(50); slider3.setPaintLabels(true); - slider3.setValue(30); slider3.putClientProperty("FlatLaf.styleClass", "flatlaf-preview-slider"); slider3.addChangeListener(e -> changeProgress()); add(slider3, "cell 1 16 2 1,width 100"); @@ -726,7 +726,7 @@ class FlatThemePreviewAll add(progressBarLabel, "cell 0 17"); //---- progressBar1 ---- - progressBar1.setValue(60); + progressBar1.setValue(50); progressBar1.putClientProperty("FlatLaf.styleClass", "flatlaf-preview-progressbar"); add(progressBar1, "cell 1 17 2 1"); diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.jfd b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.jfd index a0e3e0b6..861fcc23 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.jfd +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreviewAll.jfd @@ -1,4 +1,4 @@ -JFDML JFormDesigner: "999.9.9.9.9999" Java: "1.8.0_202" encoding: "UTF-8" +JFDML JFormDesigner: "7.0.5.0.404" Java: "17" encoding: "UTF-8" new FormModel { contentType: "form/swing" @@ -444,6 +444,7 @@ new FormModel { name: "scrollBar1" "orientation": 0 "$client.FlatLaf.styleClass": "flatlaf-preview-scrollbar" + "visibleAmount": 50 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 12 2 1" } ) @@ -452,6 +453,7 @@ new FormModel { "orientation": 0 "showButtons": true "$client.FlatLaf.styleClass": "flatlaf-preview-scrollbar" + "visibleAmount": 50 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 13 2 1" } ) @@ -475,7 +477,6 @@ new FormModel { } ) add( new FormComponent( "javax.swing.JSlider" ) { name: "slider1" - "value": 30 "$client.FlatLaf.styleClass": "flatlaf-preview-slider" auxiliary() { "JavaCodeGenerator.variableLocal": false @@ -489,7 +490,6 @@ new FormModel { "paintTicks": true "majorTickSpacing": 50 "paintLabels": true - "value": 30 "$client.FlatLaf.styleClass": "flatlaf-preview-slider" auxiliary() { "JavaCodeGenerator.variableLocal": false @@ -506,7 +506,7 @@ new FormModel { } ) add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatProgressBar" ) { name: "progressBar1" - "value": 60 + "value": 50 "$client.FlatLaf.styleClass": "flatlaf-preview-progressbar" auxiliary() { "JavaCodeGenerator.variableLocal": false diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java index eb42fff7..0be381c8 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java @@ -117,6 +117,21 @@ class FlatThemePropertiesSupport int endOffset = textArea.getLineEndOffset( line ); String text = textArea.getText( startOffset, endOffset - startOffset ); + // remove trailing backslash from multi-line properties usually used for styles + if( text.endsWith( "\\\n" ) ) + text = text.substring( 0, text.length() - 2 ).trim(); + // remove trailing semicolon from styles + if( text.endsWith( ";" ) ) + text = text.substring( 0, text.length() - 1 ).trim(); + + // remove key starting with "[style]" so that first property name + // in CSS styled value is used as key to detect value type + if( text.startsWith( "[style]" ) ) { + int sepIndex = text.indexOf( '=' ); + if( sepIndex >= 0 ) + text = text.substring( sepIndex + 1 ); + } + Properties properties = new Properties(); properties.load( new StringReader( text ) ); if( properties.isEmpty() ) diff --git a/flatlaf-theme-editor/theme-editor-test.properties b/flatlaf-theme-editor/theme-editor-test.properties index 52973641..fa4bf4e5 100644 --- a/flatlaf-theme-editor/theme-editor-test.properties +++ b/flatlaf-theme-editor/theme-editor-test.properties @@ -122,3 +122,9 @@ Prop.7.selectionForeground = contrast($Prop.7.selectionBackground,#000,#fff) @varStyle1 = #f0f [style].style1 = background: @varStyle1 + +[style].style2 = background: darken(#f00,10%); \ + foreground: #0f0; \ + foreground: darken(@background,30%); \ + toolbar.hoverBackground: fade(Actions.GreyInline,30%,lazy); \ + toolbar.selectedBackground: fade(Actions.GreyInline,50%,lazy)