From 923d58519f6ea5b7619a107a53a9a5efab37af4e Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Thu, 10 Dec 2020 20:30:27 +0100 Subject: [PATCH] Extras: added extension interfaces and classes for JComboBox, JFormattedTextField, JPasswordField, JScrollBar, JScrollPane and JTextField (issue #117) --- .../extras/components/FlatComboBox.java | 32 ++++++++ .../components/FlatFormattedTextField.java | 32 ++++++++ .../extras/components/FlatPasswordField.java | 32 ++++++++ .../extras/components/FlatScrollBar.java | 32 ++++++++ .../extras/components/FlatScrollPane.java | 32 ++++++++ .../extras/components/FlatTextField.java | 32 ++++++++ .../extensions/FlatComboBoxExtension.java | 48 ++++++++++++ .../extensions/FlatComponentExtension.java | 65 +++++++++++++++++ .../extensions/FlatScrollBarExtension.java | 49 +++++++++++++ .../extensions/FlatScrollPaneExtension.java | 64 ++++++++++++++++ .../extensions/FlatTextFieldExtension.java | 73 +++++++++++++++++++ .../flatlaf/testing/FlatComponentsTest.java | 33 +++++---- .../flatlaf/testing/FlatComponentsTest.jfd | 32 ++++---- 13 files changed, 524 insertions(+), 32 deletions(-) create mode 100644 flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatComboBox.java create mode 100644 flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatFormattedTextField.java create mode 100644 flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatPasswordField.java create mode 100644 flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatScrollBar.java create mode 100644 flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatScrollPane.java create mode 100644 flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextField.java create mode 100644 flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatComboBoxExtension.java create mode 100644 flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatComponentExtension.java create mode 100644 flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatScrollBarExtension.java create mode 100644 flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatScrollPaneExtension.java create mode 100644 flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatTextFieldExtension.java diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatComboBox.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatComboBox.java new file mode 100644 index 00000000..1e90718d --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatComboBox.java @@ -0,0 +1,32 @@ +/* + * Copyright 2020 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.extras.components; + +import javax.swing.JComboBox; +import com.formdev.flatlaf.extras.components.extensions.FlatComboBoxExtension; + +/** + * Subclass of {@link JComboBox} that implements {@link FlatComboBoxExtension} + * to provide easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + */ +public class FlatComboBox + extends JComboBox + implements FlatComboBoxExtension +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatFormattedTextField.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatFormattedTextField.java new file mode 100644 index 00000000..b2c11342 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatFormattedTextField.java @@ -0,0 +1,32 @@ +/* + * Copyright 2020 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.extras.components; + +import javax.swing.JFormattedTextField; +import com.formdev.flatlaf.extras.components.extensions.FlatTextFieldExtension; + +/** + * Subclass of {@link JFormattedTextField} that implements {@link FlatTextFieldExtension} + * to provide easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + */ +public class FlatFormattedTextField + extends JFormattedTextField + implements FlatTextFieldExtension +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatPasswordField.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatPasswordField.java new file mode 100644 index 00000000..6c172e68 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatPasswordField.java @@ -0,0 +1,32 @@ +/* + * Copyright 2020 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.extras.components; + +import javax.swing.JPasswordField; +import com.formdev.flatlaf.extras.components.extensions.FlatTextFieldExtension; + +/** + * Subclass of {@link JPasswordField} that implements {@link FlatTextFieldExtension} + * to provide easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + */ +public class FlatPasswordField + extends JPasswordField + implements FlatTextFieldExtension +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatScrollBar.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatScrollBar.java new file mode 100644 index 00000000..cba09974 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatScrollBar.java @@ -0,0 +1,32 @@ +/* + * Copyright 2020 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.extras.components; + +import javax.swing.JScrollBar; +import com.formdev.flatlaf.extras.components.extensions.FlatScrollBarExtension; + +/** + * Subclass of {@link JScrollBar} that implements {@link FlatScrollBarExtension} + * to provide easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + */ +public class FlatScrollBar + extends JScrollBar + implements FlatScrollBarExtension +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatScrollPane.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatScrollPane.java new file mode 100644 index 00000000..07f70db5 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatScrollPane.java @@ -0,0 +1,32 @@ +/* + * Copyright 2020 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.extras.components; + +import javax.swing.JScrollPane; +import com.formdev.flatlaf.extras.components.extensions.FlatScrollPaneExtension; + +/** + * Subclass of {@link JScrollPane} that implements {@link FlatScrollPaneExtension} + * to provide easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + */ +public class FlatScrollPane + extends JScrollPane + implements FlatScrollPaneExtension +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextField.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextField.java new file mode 100644 index 00000000..45c49e5b --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextField.java @@ -0,0 +1,32 @@ +/* + * Copyright 2020 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.extras.components; + +import javax.swing.JTextField; +import com.formdev.flatlaf.extras.components.extensions.FlatTextFieldExtension; + +/** + * Subclass of {@link JTextField} that implements {@link FlatTextFieldExtension} + * to provide easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + */ +public class FlatTextField + extends JTextField + implements FlatTextFieldExtension +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatComboBoxExtension.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatComboBoxExtension.java new file mode 100644 index 00000000..b259ce81 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatComboBoxExtension.java @@ -0,0 +1,48 @@ +/* + * Copyright 2020 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.extras.components.extensions; + +import static com.formdev.flatlaf.FlatClientProperties.*; +import javax.swing.JComboBox; + +/** + * Extension interface for {@link JComboBox} that provides + * easy access to FlatLaf specific client properties. + *

+ * Use this interface if you already have a subclass of {@link JComboBox} + * in your project and want add access to FlatLaf features to your class. + * Otherwise use {@link FlatComboBox}. + * + * @author Karl Tauber + */ +public interface FlatComboBoxExtension + extends FlatComponentExtension +{ + /** + * Returns the placeholder text that is only painted if the editable combo box is empty. + */ + default String getPlaceholderText() { + return (String) getClientProperty( PLACEHOLDER_TEXT ); + } + + /** + * Sets the placeholder text that is only painted if the editable combo box is empty. + */ + default void setPlaceholderText( String placeholderText ) { + putClientProperty( PLACEHOLDER_TEXT, placeholderText ); + } +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatComponentExtension.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatComponentExtension.java new file mode 100644 index 00000000..f3744282 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatComponentExtension.java @@ -0,0 +1,65 @@ +/* + * Copyright 2020 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.extras.components.extensions; + +import javax.swing.JComponent; +import javax.swing.UIManager; + +/** + * Base interface for all FlatLaf component extensions. + * Extensions use client properties to store property values in components. + * + * @author Karl Tauber + */ +public interface FlatComponentExtension +{ + /** + * Overrides {@link JComponent#getClientProperty(Object)}. + */ + Object getClientProperty( Object key ); + + /** + * Overrides {@link JComponent#putClientProperty(Object, Object)}. + */ + void putClientProperty( Object key, Object value ); + + + default boolean getClientPropertyBoolean( Object key, String defaultValueKey ) { + Object value = getClientProperty( key ); + return (value instanceof Boolean) ? (boolean) value : UIManager.getBoolean( defaultValueKey ); + } + + default > T getClientPropertyEnumString( Object key, Class enumType, + String defaultValueKey, T defaultValue ) + { + Object value = getClientProperty( key ); + if( !(value instanceof String) && defaultValueKey != null ) + value = UIManager.getString( defaultValueKey ); + if( value instanceof String ) { + try { + return Enum.valueOf( enumType, (String) value ); + } catch( IllegalArgumentException ex ) { + ex.printStackTrace(); + } + } + return defaultValue; + } + + default > void putClientPropertyEnumString( Object key, Enum value ) { + putClientProperty( key, (value != null) ? value.toString() : null ); + } +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatScrollBarExtension.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatScrollBarExtension.java new file mode 100644 index 00000000..007216f7 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatScrollBarExtension.java @@ -0,0 +1,49 @@ +/* + * Copyright 2020 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.extras.components.extensions; + +import static com.formdev.flatlaf.FlatClientProperties.*; +import javax.swing.JScrollBar; +import com.formdev.flatlaf.extras.components.FlatScrollBar; + +/** + * Extension interface for {@link JScrollBar} that provides + * easy access to FlatLaf specific client properties. + *

+ * Use this interface if you already have a subclass of {@link JScrollBar} + * in your project and want add access to FlatLaf features to your class. + * Otherwise use {@link FlatScrollBar}. + * + * @author Karl Tauber + */ +public interface FlatScrollBarExtension + extends FlatComponentExtension +{ + /** + * Returns whether the decrease/increase arrow buttons of a scrollbar are shown. + */ + default boolean isShowButtons() { + return getClientPropertyBoolean( SCROLL_BAR_SHOW_BUTTONS, "ScrollBar.showButtons" ); + } + + /** + * Specifies whether the decrease/increase arrow buttons of a scrollbar are shown. + */ + default void setShowButtons( boolean showButtons ) { + putClientProperty( SCROLL_BAR_SHOW_BUTTONS, showButtons ); + } +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatScrollPaneExtension.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatScrollPaneExtension.java new file mode 100644 index 00000000..52439157 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatScrollPaneExtension.java @@ -0,0 +1,64 @@ +/* + * Copyright 2020 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.extras.components.extensions; + +import static com.formdev.flatlaf.FlatClientProperties.*; +import javax.swing.JScrollPane; +import com.formdev.flatlaf.extras.components.FlatScrollPane; + +/** + * Extension interface for {@link JScrollPane} that provides + * easy access to FlatLaf specific client properties. + *

+ * Use this interface if you already have a subclass of {@link JScrollPane} + * in your project and want add access to FlatLaf features to your class. + * Otherwise use {@link FlatScrollPane}. + * + * @author Karl Tauber + */ +public interface FlatScrollPaneExtension + extends FlatComponentExtension +{ + /** + * Returns whether the decrease/increase arrow buttons of a scrollbar are shown. + */ + default boolean isShowButtons() { + return getClientPropertyBoolean( SCROLL_BAR_SHOW_BUTTONS, "ScrollBar.showButtons" ); + } + + /** + * Specifies whether the decrease/increase arrow buttons of a scrollbar are shown. + */ + default void setShowButtons( boolean showButtons ) { + putClientProperty( SCROLL_BAR_SHOW_BUTTONS, showButtons ); + } + + + /** + * Returns whether the scroll pane uses smooth scrolling. + */ + default boolean isSmoothScrolling() { + return getClientPropertyBoolean( SCROLL_PANE_SMOOTH_SCROLLING, "ScrollPane.smoothScrolling" ); + } + + /** + * Specifies whether the scroll pane uses smooth scrolling. + */ + default void setSmoothScrolling( boolean smoothScrolling ) { + putClientProperty( SCROLL_PANE_SMOOTH_SCROLLING, smoothScrolling ); + } +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatTextFieldExtension.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatTextFieldExtension.java new file mode 100644 index 00000000..d317a68e --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/extensions/FlatTextFieldExtension.java @@ -0,0 +1,73 @@ +/* + * Copyright 2020 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.extras.components.extensions; + +import static com.formdev.flatlaf.FlatClientProperties.*; +import javax.swing.JFormattedTextField; +import javax.swing.JPasswordField; +import javax.swing.JTextField; +import com.formdev.flatlaf.extras.components.FlatFormattedTextField; +import com.formdev.flatlaf.extras.components.FlatPasswordField; +import com.formdev.flatlaf.extras.components.FlatTextField; + +/** + * Extension interface for {@link JTextField} (and subclasses) that provides + * easy access to FlatLaf specific client properties. + *

+ * Use this interface if you already have a subclass of {@link JTextField}, + * {@link JFormattedTextField} or {@link JPasswordField} + * in your project and want add access to FlatLaf features to your class. + * Otherwise use {@link FlatTextField}, {@link FlatFormattedTextField} or {@link FlatPasswordField}. + * + * @author Karl Tauber + */ +public interface FlatTextFieldExtension + extends FlatComponentExtension +{ + /** + * Returns the placeholder text that is only painted if the text field is empty. + */ + default String getPlaceholderText() { + return (String) getClientProperty( PLACEHOLDER_TEXT ); + } + + /** + * Sets the placeholder text that is only painted if the text field is empty. + */ + default void setPlaceholderText( String placeholderText ) { + putClientProperty( PLACEHOLDER_TEXT, placeholderText ); + } + + + // NOTE: enum names must be equal to allowed strings + enum SelectAllOnFocusPolicy { never, once, always }; + + /** + * Returns whether all text is selected when the text component gains focus. + */ + default SelectAllOnFocusPolicy getSelectAllOnFocusPolicy() { + return getClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, SelectAllOnFocusPolicy.class, + "TextComponent.selectAllOnFocusPolicy", SelectAllOnFocusPolicy.once ); + } + + /** + * Specifies whether all text is selected when the text component gains focus. + */ + default void setSelectAllOnFocusPolicy( SelectAllOnFocusPolicy selectAllOnFocusPolicy ) { + putClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, selectAllOnFocusPolicy ); + } +} diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java index 5e308623..73ef3f10 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java @@ -20,6 +20,7 @@ import java.awt.*; import javax.swing.*; import javax.swing.border.*; import com.formdev.flatlaf.FlatClientProperties; +import com.formdev.flatlaf.extras.components.*; import net.miginfocom.swing.*; /** @@ -188,28 +189,28 @@ public class FlatComponentsTest JSpinner spinner2 = new JSpinner(); FlatComponentsTest.ButtonlessSpinner buttonlessSpinner1 = new FlatComponentsTest.ButtonlessSpinner(); FlatComponentsTest.ButtonlessSpinner buttonlessSpinner2 = new FlatComponentsTest.ButtonlessSpinner(); - JComboBox comboBox7 = new JComboBox<>(); + FlatComboBox comboBox7 = new FlatComboBox<>(); JSpinner spinner3 = new JSpinner(); JLabel textFieldLabel = new JLabel(); textField1 = new JTextField(); JTextField textField2 = new JTextField(); JTextField textField3 = new JTextField(); JTextField textField4 = new JTextField(); - JTextField textField6 = new JTextField(); + FlatTextField textField6 = new FlatTextField(); JTextField textField5 = new JTextField(); JLabel formattedTextFieldLabel = new JLabel(); JFormattedTextField formattedTextField1 = new JFormattedTextField(); JFormattedTextField formattedTextField2 = new JFormattedTextField(); JFormattedTextField formattedTextField3 = new JFormattedTextField(); JFormattedTextField formattedTextField4 = new JFormattedTextField(); - JFormattedTextField formattedTextField5 = new JFormattedTextField(); + FlatFormattedTextField formattedTextField5 = new FlatFormattedTextField(); JFormattedTextField formattedTextField6 = new JFormattedTextField(); JLabel passwordFieldLabel = new JLabel(); JPasswordField passwordField1 = new JPasswordField(); JPasswordField passwordField2 = new JPasswordField(); JPasswordField passwordField3 = new JPasswordField(); JPasswordField passwordField4 = new JPasswordField(); - JPasswordField passwordField5 = new JPasswordField(); + FlatPasswordField passwordField5 = new FlatPasswordField(); JPasswordField passwordField6 = new JPasswordField(); JLabel textAreaLabel = new JLabel(); JScrollPane scrollPane1 = new JScrollPane(); @@ -247,8 +248,8 @@ public class FlatComponentsTest JButton button19 = new JButton(); JScrollBar scrollBar2 = new JScrollBar(); JScrollBar scrollBar3 = new JScrollBar(); - JScrollBar scrollBar7 = new JScrollBar(); - JScrollBar scrollBar8 = new JScrollBar(); + FlatScrollBar scrollBar7 = new FlatScrollBar(); + FlatScrollBar scrollBar8 = new FlatScrollBar(); JSeparator separator2 = new JSeparator(); JSlider slider2 = new JSlider(); JSlider slider4 = new JSlider(); @@ -278,8 +279,8 @@ public class FlatComponentsTest JLabel scrollBarLabel = new JLabel(); JScrollBar scrollBar1 = new JScrollBar(); JScrollBar scrollBar4 = new JScrollBar(); - JScrollBar scrollBar5 = new JScrollBar(); - JScrollBar scrollBar6 = new JScrollBar(); + FlatScrollBar scrollBar5 = new FlatScrollBar(); + FlatScrollBar scrollBar6 = new FlatScrollBar(); JLabel separatorLabel = new JLabel(); JSeparator separator1 = new JSeparator(); JPanel panel2 = new JPanel(); @@ -686,7 +687,7 @@ public class FlatComponentsTest //---- comboBox7 ---- comboBox7.setEditable(true); - comboBox7.putClientProperty("JTextField.placeholderText", "Placeholder"); + comboBox7.setPlaceholderText("Placeholder"); add(comboBox7, "cell 5 6,growx"); //---- spinner3 ---- @@ -719,7 +720,7 @@ public class FlatComponentsTest add(textField4, "cell 4 7,growx"); //---- textField6 ---- - textField6.putClientProperty("JTextField.placeholderText", "Placeholder"); + textField6.setPlaceholderText("Placeholder"); add(textField6, "cell 5 7,growx"); //---- textField5 ---- @@ -752,7 +753,7 @@ public class FlatComponentsTest add(formattedTextField4, "cell 4 8,growx"); //---- formattedTextField5 ---- - formattedTextField5.putClientProperty("JTextField.placeholderText", "Placeholder"); + formattedTextField5.setPlaceholderText("Placeholder"); add(formattedTextField5, "cell 5 8,growx"); //---- formattedTextField6 ---- @@ -785,7 +786,7 @@ public class FlatComponentsTest add(passwordField4, "cell 4 9,growx"); //---- passwordField5 ---- - passwordField5.putClientProperty("JTextField.placeholderText", "Placeholder"); + passwordField5.setPlaceholderText("Placeholder"); add(passwordField5, "cell 5 9,growx"); //---- passwordField6 ---- @@ -996,12 +997,12 @@ public class FlatComponentsTest add(scrollBar3, "cell 2 13 1 6,growy"); //---- scrollBar7 ---- - scrollBar7.putClientProperty("JScrollBar.showButtons", true); + scrollBar7.setShowButtons(true); add(scrollBar7, "cell 2 13 1 6,growy"); //---- scrollBar8 ---- scrollBar8.setEnabled(false); - scrollBar8.putClientProperty("JScrollBar.showButtons", true); + scrollBar8.setShowButtons(true); add(scrollBar8, "cell 2 13 1 6,growy"); //---- separator2 ---- @@ -1173,13 +1174,13 @@ public class FlatComponentsTest //---- scrollBar5 ---- scrollBar5.setOrientation(Adjustable.HORIZONTAL); - scrollBar5.putClientProperty("JScrollBar.showButtons", true); + scrollBar5.setShowButtons(true); add(scrollBar5, "cell 1 16,growx"); //---- scrollBar6 ---- scrollBar6.setOrientation(Adjustable.HORIZONTAL); scrollBar6.setEnabled(false); - scrollBar6.putClientProperty("JScrollBar.showButtons", true); + scrollBar6.setShowButtons(true); add(scrollBar6, "cell 1 17,growx"); //---- separatorLabel ---- diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd index 324865e1..7e8c7633 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd @@ -466,10 +466,10 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 4 6,growx" } ) - add( new FormComponent( "javax.swing.JComboBox" ) { + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatComboBox" ) { name: "comboBox7" "editable": true - "$client.JTextField.placeholderText": "Placeholder" + "placeholderText": "Placeholder" auxiliary() { "JavaCodeGenerator.typeParameters": "String" } @@ -522,9 +522,9 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 4 7,growx" } ) - add( new FormComponent( "javax.swing.JTextField" ) { + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTextField" ) { name: "textField6" - "$client.JTextField.placeholderText": "Placeholder" + "placeholderText": "Placeholder" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 5 7,growx" } ) @@ -569,9 +569,9 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 4 8,growx" } ) - add( new FormComponent( "javax.swing.JFormattedTextField" ) { + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatFormattedTextField" ) { name: "formattedTextField5" - "$client.JTextField.placeholderText": "Placeholder" + "placeholderText": "Placeholder" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 5 8,growx" } ) @@ -616,9 +616,9 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 4 9,growx" } ) - add( new FormComponent( "javax.swing.JPasswordField" ) { + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatPasswordField" ) { name: "passwordField5" - "$client.JTextField.placeholderText": "Placeholder" + "placeholderText": "Placeholder" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 5 9,growx" } ) @@ -850,16 +850,16 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 2 13 1 6,growy" } ) - add( new FormComponent( "javax.swing.JScrollBar" ) { + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatScrollBar" ) { name: "scrollBar7" - "$client.JScrollBar.showButtons": true + "showButtons": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 2 13 1 6,growy" } ) - add( new FormComponent( "javax.swing.JScrollBar" ) { + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatScrollBar" ) { name: "scrollBar8" "enabled": false - "$client.JScrollBar.showButtons": true + "showButtons": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 2 13 1 6,growy" } ) @@ -1098,18 +1098,18 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 15,growx" } ) - add( new FormComponent( "javax.swing.JScrollBar" ) { + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatScrollBar" ) { name: "scrollBar5" "orientation": 0 - "$client.JScrollBar.showButtons": true + "showButtons": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 16,growx" } ) - add( new FormComponent( "javax.swing.JScrollBar" ) { + add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatScrollBar" ) { name: "scrollBar6" "orientation": 0 "enabled": false - "$client.JScrollBar.showButtons": true + "showButtons": true }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 17,growx" } )