diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java index 8f107a42..0d83eb42 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java @@ -127,12 +127,21 @@ public interface FlatClientProperties //---- JComponent --------------------------------------------------------- /** - * Specifies the style of a component in CSS syntax ("key1: value1; key2: value2; ..."). + * Specifies the style of a component as String in CSS syntax ("key1: value1; key2: value2; ...") + * or as {@link java.util.Map}<String, Object> with binary values. + *

+ * The keys are the same as used in UI defaults, but without component type prefix. + * E.g. for UI default {@code Slider.thumbSize} use key {@code thumbSize}. + *

+ * The syntax of the CSS values is the same as used in FlatLaf properties files + * (https://www.formdev.com/flatlaf/properties-files/), + * but some features are not supported (e.g. variables). + * When using a map, the values are not parsed from a string. They must be binary. *

* Components {@link javax.swing.JComponent}
* Value type {@link java.lang.String} or {@link java.util.Map}<String, Object>
* - * @since TODO + * @since 2 */ String STYLE = "FlatLaf.style"; diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatButton.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatButton.java index 38434c28..4b290775 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatButton.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatButton.java @@ -27,7 +27,7 @@ import javax.swing.JButton; */ public class FlatButton extends JButton - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { // NOTE: enum names must be equal to allowed strings public enum ButtonType { none, square, roundRect, tab, help, toolBarButton, borderless } diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatCheckBox.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatCheckBox.java new file mode 100644 index 00000000..bfdc60b5 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatCheckBox.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JCheckBox; + +/** + * Subclass of {@link JCheckBox} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatCheckBox + extends JCheckBox + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatCheckBoxMenuItem.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatCheckBoxMenuItem.java new file mode 100644 index 00000000..711d91e0 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatCheckBoxMenuItem.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JCheckBoxMenuItem; + +/** + * Subclass of {@link JCheckBoxMenuItem} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatCheckBoxMenuItem + extends JCheckBoxMenuItem + implements FlatStyleableComponent +{ +} 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 index 6b9581c7..79e44158 100644 --- 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 @@ -27,7 +27,7 @@ import javax.swing.JComboBox; */ public class FlatComboBox extends JComboBox - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { /** * Returns the placeholder text that is only painted if the editable combo box is empty. diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatEditorPane.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatEditorPane.java index 403ccb43..02be8eff 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatEditorPane.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatEditorPane.java @@ -26,7 +26,7 @@ import javax.swing.JEditorPane; */ public class FlatEditorPane extends JEditorPane - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { /** * Returns minimum width of a component. 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 index 4ebc554d..fe030a95 100644 --- 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 @@ -29,7 +29,7 @@ import com.formdev.flatlaf.extras.components.FlatTextField.SelectAllOnFocusPolic */ public class FlatFormattedTextField extends JFormattedTextField - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { /** * Returns the placeholder text that is only painted if the text field is empty. diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatInternalFrame.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatInternalFrame.java new file mode 100644 index 00000000..cdc09538 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatInternalFrame.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JInternalFrame; + +/** + * Subclass of {@link JInternalFrame} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatInternalFrame + extends JInternalFrame + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatLabel.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatLabel.java new file mode 100644 index 00000000..2577b9a4 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatLabel.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JLabel; + +/** + * Subclass of {@link JLabel} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatLabel + extends JLabel + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatList.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatList.java new file mode 100644 index 00000000..b667e907 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatList.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JList; + +/** + * Subclass of {@link JList} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatList + extends JList + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatMenu.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatMenu.java new file mode 100644 index 00000000..407ad500 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatMenu.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JMenu; + +/** + * Subclass of {@link JMenu} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatMenu + extends JMenu + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatMenuBar.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatMenuBar.java new file mode 100644 index 00000000..b7e2520b --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatMenuBar.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JMenuBar; + +/** + * Subclass of {@link JMenuBar} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatMenuBar + extends JMenuBar + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatMenuItem.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatMenuItem.java new file mode 100644 index 00000000..5895a9aa --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatMenuItem.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JMenuItem; + +/** + * Subclass of {@link JMenuItem} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatMenuItem + extends JMenuItem + implements FlatStyleableComponent +{ +} 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 index 86495da2..3a9b027a 100644 --- 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 @@ -29,7 +29,7 @@ import com.formdev.flatlaf.extras.components.FlatTextField.SelectAllOnFocusPolic */ public class FlatPasswordField extends JPasswordField - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { /** * Returns the placeholder text that is only painted if the text field is empty. diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatPopupMenu.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatPopupMenu.java new file mode 100644 index 00000000..e16757e5 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatPopupMenu.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JPopupMenu; + +/** + * Subclass of {@link JPopupMenu} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatPopupMenu + extends JPopupMenu + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatPopupMenuSeparator.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatPopupMenuSeparator.java new file mode 100644 index 00000000..37f0abb2 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatPopupMenuSeparator.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JPopupMenu; + +/** + * Subclass of {@link JPopupMenu.Separator} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatPopupMenuSeparator + extends JPopupMenu.Separator + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatProgressBar.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatProgressBar.java index c4698374..d0ede426 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatProgressBar.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatProgressBar.java @@ -26,7 +26,7 @@ import javax.swing.JProgressBar; */ public class FlatProgressBar extends JProgressBar - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { /** * Returns whether the progress bar has always the larger height even if no string is painted. diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatRadioButton.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatRadioButton.java new file mode 100644 index 00000000..f19b0a04 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatRadioButton.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JRadioButton; + +/** + * Subclass of {@link JRadioButton} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatRadioButton + extends JRadioButton + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatRadioButtonMenuItem.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatRadioButtonMenuItem.java new file mode 100644 index 00000000..6185ba61 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatRadioButtonMenuItem.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JRadioButtonMenuItem; + +/** + * Subclass of {@link JRadioButtonMenuItem} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatRadioButtonMenuItem + extends JRadioButtonMenuItem + implements FlatStyleableComponent +{ +} 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 index eba79afe..7d0a2fd1 100644 --- 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 @@ -26,7 +26,7 @@ import javax.swing.JScrollBar; */ public class FlatScrollBar extends JScrollBar - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { /** * Returns whether the decrease/increase arrow buttons of a scrollbar are shown. 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 index 159b477d..f99f0d3b 100644 --- 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 @@ -27,7 +27,7 @@ import javax.swing.JScrollPane; */ public class FlatScrollPane extends JScrollPane - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { /** * Returns whether the decrease/increase arrow buttons of a scrollbar are shown. diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatSeparator.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatSeparator.java new file mode 100644 index 00000000..aa8b9a56 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatSeparator.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JSeparator; + +/** + * Subclass of {@link JSeparator} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatSeparator + extends JSeparator + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatSlider.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatSlider.java new file mode 100644 index 00000000..aa9aa6e5 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatSlider.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JSlider; + +/** + * Subclass of {@link JSlider} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatSlider + extends JSlider + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatSpinner.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatSpinner.java index f4e162f0..d9567bad 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatSpinner.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatSpinner.java @@ -27,7 +27,7 @@ import javax.swing.JSpinner; */ public class FlatSpinner extends JSpinner - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { /** * Returns minimum width of a component. diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatSplitPane.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatSplitPane.java new file mode 100644 index 00000000..846ad68e --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatSplitPane.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JSplitPane; + +/** + * Subclass of {@link JSplitPane} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatSplitPane + extends JSplitPane + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatStyleableComponent.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatStyleableComponent.java new file mode 100644 index 00000000..d2b3c70c --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatStyleableComponent.java @@ -0,0 +1,88 @@ +/* + * 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.extras.components; + +import java.util.Map; +import javax.swing.JComponent; +import com.formdev.flatlaf.FlatClientProperties; + +/** + * Interface for all styleable FlatLaf components. + *

+ * If you already have custom subclasses of Swing components, you can add this interface + * to your components to add styling getter and setter methods to them. + * + * @author Karl Tauber + * @since 2 + */ +public interface FlatStyleableComponent +{ + /** + * Returns the style of a component as String in CSS syntax ("key1: value1; key2: value2; ...") + * or {@code null} if no style has been assigned. + */ + default String getStyle() { + return (String) getClientProperty( FlatClientProperties.STYLE ); + } + + /** + * Specifies the style of a component as String in CSS syntax ("key1: value1; key2: value2; ..."). + *

+ * The keys are the same as used in UI defaults, but without component type prefix. + * E.g. for UI default {@code Slider.thumbSize} use key {@code thumbSize}. + *

+ * The syntax of the CSS values is the same as used in FlatLaf properties files + * (https://www.formdev.com/flatlaf/properties-files/), + * but some features are not supported (e.g. variables). + */ + default void setStyle( String style ) { + putClientProperty( FlatClientProperties.STYLE, style ); + } + + + /** + * Returns the style of a component as {@link java.util.Map}<String, Object> + * or {@code null} if no style has been assigned. + */ + @SuppressWarnings( "unchecked" ) + default Map getStyleMap() { + return (Map) getClientProperty( FlatClientProperties.STYLE ); + } + + /** + * Specifies the style of a component as {@link java.util.Map}<String, Object> with binary values. + *

+ * The keys are the same as used in UI defaults, but without component type prefix. + * E.g. for UI default {@code Slider.thumbSize} use key {@code thumbSize}. + *

+ * The values are not parsed from a string. They must be binary. + */ + default void setStyleMap( Map styleMap ) { + putClientProperty( FlatClientProperties.STYLE, styleMap ); + } + + + /** + * Overrides {@link JComponent#getClientProperty(Object)}. + */ + Object getClientProperty( Object key ); + + /** + * Overrides {@link JComponent#putClientProperty(Object, Object)}. + */ + void putClientProperty( Object key, Object value ); +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTabbedPane.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTabbedPane.java index bd04f9b4..22181f90 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTabbedPane.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTabbedPane.java @@ -31,7 +31,7 @@ import javax.swing.SwingConstants; */ public class FlatTabbedPane extends JTabbedPane - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { /** * Returns whether separators are shown between tabs. diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTable.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTable.java new file mode 100644 index 00000000..627517d0 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTable.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JTable; + +/** + * Subclass of {@link JTable} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatTable + extends JTable + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTableHeader.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTableHeader.java new file mode 100644 index 00000000..37e0e209 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTableHeader.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.table.JTableHeader; + +/** + * Subclass of {@link JTableHeader} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatTableHeader + extends JTableHeader + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextArea.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextArea.java index a0568d97..5ba1f7ac 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextArea.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextArea.java @@ -26,7 +26,7 @@ import javax.swing.JTextArea; */ public class FlatTextArea extends JTextArea - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { /** * Returns minimum width of a component. 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 index bfa22dd2..8c8cc56e 100644 --- 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 @@ -28,7 +28,7 @@ import javax.swing.JTextField; */ public class FlatTextField extends JTextField - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { /** * Returns the placeholder text that is only painted if the text field is empty. diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextPane.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextPane.java index 4660068a..84897ee6 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextPane.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTextPane.java @@ -26,7 +26,7 @@ import javax.swing.JTextPane; */ public class FlatTextPane extends JTextPane - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { /** * Returns minimum width of a component. diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatToggleButton.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatToggleButton.java index a342f890..226acb12 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatToggleButton.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatToggleButton.java @@ -28,7 +28,7 @@ import com.formdev.flatlaf.extras.components.FlatButton.ButtonType; */ public class FlatToggleButton extends JToggleButton - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { /** * Returns type of a button. diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatToolBar.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatToolBar.java new file mode 100644 index 00000000..3caff752 --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatToolBar.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JToolBar; + +/** + * Subclass of {@link JToolBar} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatToolBar + extends JToolBar + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatToolBarSeparator.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatToolBarSeparator.java new file mode 100644 index 00000000..37300b5d --- /dev/null +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatToolBarSeparator.java @@ -0,0 +1,31 @@ +/* + * 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.extras.components; + +import javax.swing.JToolBar; + +/** + * Subclass of {@link JToolBar.Separator} that provides easy access to FlatLaf specific client properties. + * + * @author Karl Tauber + * @since 2 + */ +public class FlatToolBarSeparator + extends JToolBar.Separator + implements FlatStyleableComponent +{ +} diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTree.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTree.java index 730b91be..83c0075c 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTree.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/components/FlatTree.java @@ -22,10 +22,11 @@ import javax.swing.JTree; /** * Subclass of {@link JTree} that provides easy access to FlatLaf specific client properties. * + * @author Karl Tauber */ public class FlatTree extends JTree - implements FlatComponentExtension + implements FlatComponentExtension, FlatStyleableComponent { /** * Returns if the tree shows a wide selection 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 02da2a64..14a3d253 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 @@ -52,7 +52,6 @@ import java.util.prefs.Preferences; import javax.lang.model.SourceVersion; import javax.swing.*; import net.miginfocom.swing.*; -import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.FlatDarculaLaf; import com.formdev.flatlaf.FlatDarkLaf; import com.formdev.flatlaf.FlatIntelliJLaf; @@ -132,8 +131,7 @@ class FlatThemeFileEditor darkLafMenuItem.setSelected( true ); // highlight selected tab - tabbedPane.putClientProperty( FlatClientProperties.STYLE, - "[light]selectedBackground: #fff; [dark]selectedBackground: #303234" ); + tabbedPane.setStyle( "[light]selectedBackground: #fff; [dark]selectedBackground: #303234" ); // add "+" button to tabbed pane newButton = new JButton( new FlatSVGIcon( "com/formdev/flatlaf/themeeditor/icons/add.svg" ) );