diff --git a/flatlaf-testing/flatlaf-testing-modular-app/FlatModularAppTest JAR.launch b/flatlaf-testing/flatlaf-testing-modular-app/FlatModularAppTest JAR.launch new file mode 100644 index 00000000..1437b0c9 --- /dev/null +++ b/flatlaf-testing/flatlaf-testing-modular-app/FlatModularAppTest JAR.launch @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/flatlaf-testing/flatlaf-testing-modular-app/build.gradle.kts b/flatlaf-testing/flatlaf-testing-modular-app/build.gradle.kts new file mode 100644 index 00000000..75c4f860 --- /dev/null +++ b/flatlaf-testing/flatlaf-testing-modular-app/build.gradle.kts @@ -0,0 +1,30 @@ +/* + * 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. + */ + +plugins { + `java-library` + `flatlaf-module-info` +} + +dependencies { + implementation( project( ":flatlaf-core" ) ) + implementation( project( ":flatlaf-extras" ) ) +} + +flatlafModuleInfo { + dependsOn( ":flatlaf-core:jar" ) + dependsOn( ":flatlaf-extras:jar" ) +} diff --git a/flatlaf-testing/flatlaf-testing-modular-app/src/main/java/com/formdev/flatlaf/testing/modular/app/FlatModularAppTest.java b/flatlaf-testing/flatlaf-testing-modular-app/src/main/java/com/formdev/flatlaf/testing/modular/app/FlatModularAppTest.java new file mode 100644 index 00000000..fb0306e0 --- /dev/null +++ b/flatlaf-testing/flatlaf-testing-modular-app/src/main/java/com/formdev/flatlaf/testing/modular/app/FlatModularAppTest.java @@ -0,0 +1,61 @@ +/* + * 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.testing.modular.app; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import com.formdev.flatlaf.FlatLaf; +import com.formdev.flatlaf.FlatLightLaf; +import com.formdev.flatlaf.extras.FlatSVGIcon; +import com.formdev.flatlaf.extras.FlatSVGUtils; + +/** + * @author Karl Tauber + */ +public class FlatModularAppTest +{ + public static void main( String[] args ) { + SwingUtilities.invokeLater( () -> { + FlatLaf.registerCustomDefaultsSource( + FlatModularAppTest.class.getResource( "/com/formdev/flatlaf/testing/modular/app/themes/" ) ); + FlatLightLaf.setup(); + + JButton button1 = new JButton( "Hello" ); + JButton button2 = new JButton( "World" ); + + button1.setIcon( new FlatSVGIcon( + FlatModularAppTest.class.getResource( "/com/formdev/flatlaf/testing/modular/app/icons/copy.svg" ) ) ); + + JPanel panel = new JPanel(); + panel.add( new JLabel( "Hello World" ) ); + panel.add( button1 ); + panel.add( button2 ); + + JFrame frame = new JFrame( "FlatModularAppTest" ); + frame.setIconImages( FlatSVGUtils.createWindowIconImages( + FlatModularAppTest.class.getResource( "/com/formdev/flatlaf/testing/modular/app/icons/copy.svg" ) ) ); + frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); + frame.getContentPane().add( panel ); + frame.pack(); + frame.setLocationRelativeTo( null ); + frame.setVisible( true ); + } ); + } +} diff --git a/flatlaf-testing/flatlaf-testing-modular-app/src/main/java/com/formdev/flatlaf/testing/modular/app/plaf/MyButtonUI.java b/flatlaf-testing/flatlaf-testing-modular-app/src/main/java/com/formdev/flatlaf/testing/modular/app/plaf/MyButtonUI.java new file mode 100644 index 00000000..4e0fe557 --- /dev/null +++ b/flatlaf-testing/flatlaf-testing-modular-app/src/main/java/com/formdev/flatlaf/testing/modular/app/plaf/MyButtonUI.java @@ -0,0 +1,36 @@ +/* + * 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.testing.modular.app.plaf; + +import javax.swing.JComponent; +import javax.swing.plaf.ComponentUI; +import com.formdev.flatlaf.ui.FlatButtonUI; + +/** + * @author Karl Tauber + */ +public class MyButtonUI + extends FlatButtonUI +{ + public static ComponentUI createUI( JComponent c ) { + return new MyButtonUI(); + } + + protected MyButtonUI() { + super( false ); + System.out.println( "MyButtonUI" ); + } +} diff --git a/flatlaf-testing/flatlaf-testing-modular-app/src/main/module-info/module-info.java b/flatlaf-testing/flatlaf-testing-modular-app/src/main/module-info/module-info.java new file mode 100644 index 00000000..87e4d76e --- /dev/null +++ b/flatlaf-testing/flatlaf-testing-modular-app/src/main/module-info/module-info.java @@ -0,0 +1,27 @@ +/* + * 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. + */ + +/** + * @author Karl Tauber + */ +module com.formdev.flatlaf.testing.modular.app { + requires java.desktop; + requires com.formdev.flatlaf; + requires com.formdev.flatlaf.extras; + requires com.kitfox.svg; + + exports com.formdev.flatlaf.testing.modular.app.plaf; +} diff --git a/flatlaf-testing/flatlaf-testing-modular-app/src/main/resources/com/formdev/flatlaf/testing/modular/app/icons/copy.svg b/flatlaf-testing/flatlaf-testing-modular-app/src/main/resources/com/formdev/flatlaf/testing/modular/app/icons/copy.svg new file mode 100644 index 00000000..2200896e --- /dev/null +++ b/flatlaf-testing/flatlaf-testing-modular-app/src/main/resources/com/formdev/flatlaf/testing/modular/app/icons/copy.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/flatlaf-testing/flatlaf-testing-modular-app/src/main/resources/com/formdev/flatlaf/testing/modular/app/themes/FlatLightLaf.properties b/flatlaf-testing/flatlaf-testing-modular-app/src/main/resources/com/formdev/flatlaf/testing/modular/app/themes/FlatLightLaf.properties new file mode 100644 index 00000000..4b52328e --- /dev/null +++ b/flatlaf-testing/flatlaf-testing-modular-app/src/main/resources/com/formdev/flatlaf/testing/modular/app/themes/FlatLightLaf.properties @@ -0,0 +1,20 @@ +# +# 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. +# + +@background = #fff +@foreground = #f00 + +ButtonUI = com.formdev.flatlaf.testing.modular.app.plaf.MyButtonUI diff --git a/settings.gradle.kts b/settings.gradle.kts index 8acdb6d6..335c5faa 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -27,6 +27,7 @@ include( "flatlaf-theme-editor" ) includeProject( "flatlaf-natives-windows", "flatlaf-natives/flatlaf-natives-windows" ) includeProject( "flatlaf-natives-jna", "flatlaf-natives/flatlaf-natives-jna" ) +includeProject( "flatlaf-testing-modular-app", "flatlaf-testing/flatlaf-testing-modular-app" ) fun includeProject( projectPath: String, projectDir: String ) { include( projectPath )