From ba35fb75258265e7f09afcd65565414f2dd841f9 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Fri, 21 Feb 2020 22:28:58 +0100 Subject: [PATCH] Panel: added UI delegate --- .../com/formdev/flatlaf/ui/FlatPanelUI.java | 45 +++++++++++++++++++ .../com/formdev/flatlaf/FlatLaf.properties | 1 + .../uidefaults/FlatDarkLaf_1.8.0_202-mac.txt | 2 +- .../uidefaults/FlatDarkLaf_1.8.0_202.txt | 2 +- .../uidefaults/FlatLightLaf_1.8.0_202-mac.txt | 2 +- .../uidefaults/FlatLightLaf_1.8.0_202.txt | 2 +- 6 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPanelUI.java diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPanelUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPanelUI.java new file mode 100644 index 00000000..cc931df6 --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPanelUI.java @@ -0,0 +1,45 @@ +/* + * 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.ui; + +import javax.swing.JComponent; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicPanelUI; + +/** + * Provides the Flat LaF UI delegate for {@link javax.swing.JPanel}. + * + * + * + * @uiDefault Panel.font Font unused + * @uiDefault Panel.background Color only used if opaque + * @uiDefault Panel.foreground Color + * @uiDefault Panel.border Border + * + * @author Karl Tauber + */ +public class FlatPanelUI + extends BasicPanelUI +{ + private static ComponentUI instance; + + public static ComponentUI createUI( JComponent c ) { + if( instance == null ) + instance = new FlatPanelUI(); + return instance; + } +} diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties index e0ff7699..8c6695ed 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -33,6 +33,7 @@ MenuUI=com.formdev.flatlaf.ui.FlatMenuUI MenuBarUI=com.formdev.flatlaf.ui.FlatMenuBarUI MenuItemUI=com.formdev.flatlaf.ui.FlatMenuItemUI OptionPaneUI=com.formdev.flatlaf.ui.FlatOptionPaneUI +PanelUI=com.formdev.flatlaf.ui.FlatPanelUI PasswordFieldUI=com.formdev.flatlaf.ui.FlatPasswordFieldUI PopupMenuUI=com.formdev.flatlaf.ui.FlatPopupMenuUI PopupMenuSeparatorUI=com.formdev.flatlaf.ui.FlatPopupMenuSeparatorUI diff --git a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatDarkLaf_1.8.0_202-mac.txt b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatDarkLaf_1.8.0_202-mac.txt index 0529354b..0dcd23fd 100644 --- a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatDarkLaf_1.8.0_202-mac.txt +++ b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatDarkLaf_1.8.0_202-mac.txt @@ -758,7 +758,7 @@ Panel.background #3c3f41 javax.swing.plaf.ColorUIResource [UI] Panel.font .SF NS Text plain 12 javax.swing.plaf.FontUIResource [UI] Panel.foreground #bbbbbb javax.swing.plaf.ColorUIResource [UI] Panel.opaque true -PanelUI com.apple.laf.AquaPanelUI +PanelUI com.formdev.flatlaf.ui.FlatPanelUI #---- PasswordField ---- diff --git a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatDarkLaf_1.8.0_202.txt b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatDarkLaf_1.8.0_202.txt index 4645bb71..2f0a182f 100644 --- a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatDarkLaf_1.8.0_202.txt +++ b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatDarkLaf_1.8.0_202.txt @@ -591,7 +591,7 @@ OptionPaneUI com.formdev.flatlaf.ui.FlatOptionPaneUI Panel.background #3c3f41 javax.swing.plaf.ColorUIResource [UI] Panel.font Segoe UI plain 12 javax.swing.plaf.FontUIResource [UI] Panel.foreground #bbbbbb javax.swing.plaf.ColorUIResource [UI] -PanelUI javax.swing.plaf.basic.BasicPanelUI +PanelUI com.formdev.flatlaf.ui.FlatPanelUI #---- PasswordField ---- diff --git a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatLightLaf_1.8.0_202-mac.txt b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatLightLaf_1.8.0_202-mac.txt index 038925b3..dead3624 100644 --- a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatLightLaf_1.8.0_202-mac.txt +++ b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatLightLaf_1.8.0_202-mac.txt @@ -760,7 +760,7 @@ Panel.background #f2f2f2 javax.swing.plaf.ColorUIResource [UI] Panel.font .SF NS Text plain 12 javax.swing.plaf.FontUIResource [UI] Panel.foreground #000000 javax.swing.plaf.ColorUIResource [UI] Panel.opaque true -PanelUI com.apple.laf.AquaPanelUI +PanelUI com.formdev.flatlaf.ui.FlatPanelUI #---- PasswordField ---- diff --git a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatLightLaf_1.8.0_202.txt b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatLightLaf_1.8.0_202.txt index 5829f9a2..d48e7bee 100644 --- a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatLightLaf_1.8.0_202.txt +++ b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/uidefaults/FlatLightLaf_1.8.0_202.txt @@ -593,7 +593,7 @@ OptionPaneUI com.formdev.flatlaf.ui.FlatOptionPaneUI Panel.background #f2f2f2 javax.swing.plaf.ColorUIResource [UI] Panel.font Segoe UI plain 12 javax.swing.plaf.FontUIResource [UI] Panel.foreground #000000 javax.swing.plaf.ColorUIResource [UI] -PanelUI javax.swing.plaf.basic.BasicPanelUI +PanelUI com.formdev.flatlaf.ui.FlatPanelUI #---- PasswordField ----