diff --git a/CHANGELOG.md b/CHANGELOG.md index 58310336..3e137141 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ FlatLaf Change Log ## Unreleased - Support using IntelliJ platform themes (.theme.json files). +- Support `JFileChooser`. (issue #5) - Fixed selection background of checkbox in table cell. - Fixed jittery submenu rendering on Mac. (issue #10) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java index 53a8aebf..00050ea2 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java @@ -171,6 +171,9 @@ public abstract class FlatLaf public UIDefaults getDefaults() { UIDefaults defaults = getBase().getDefaults(); + // add Metal resource bundle, which is required for FlatFileChooserUI + defaults.addResourceBundle( "com.sun.swing.internal.plaf.metal.resources.metal" ); + // initialize some defaults (for overriding) that are used in basic UI delegates, // but are not set in MetalLookAndFeel or BasicLookAndFeel Color control = defaults.getColor( "control" ); diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatFileChooserUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatFileChooserUI.java new file mode 100644 index 00000000..be83f016 --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatFileChooserUI.java @@ -0,0 +1,41 @@ +/* + * Copyright 2019 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 + * + * http://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.JFileChooser; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.metal.MetalFileChooserUI; + +/** + * Provides the Flat LaF UI delegate for {@link javax.swing.JFileChooser}. + * + * TODO document used UI defaults of superclass + * + * @author Karl Tauber + */ +public class FlatFileChooserUI + extends MetalFileChooserUI +{ + public static ComponentUI createUI( JComponent c ) { + return new FlatFileChooserUI( (JFileChooser) c ); + } + + public FlatFileChooserUI( JFileChooser filechooser ) { + super( filechooser ); + } +} diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java index 7cf3b895..71d4d31f 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java @@ -81,8 +81,10 @@ public class FlatTableHeaderUI @Override public void paint( Graphics g, JComponent c ) { // do not paint borders if JTableHeader.setDefaultRenderer() was used - boolean paintBorders = header.getDefaultRenderer().getClass().getName().equals( - "sun.swing.table.DefaultTableCellHeaderRenderer" ); + String rendererClassName = header.getDefaultRenderer().getClass().getName(); + boolean paintBorders = + rendererClassName.equals( "sun.swing.table.DefaultTableCellHeaderRenderer" ) || + rendererClassName.equals( "sun.swing.FilePane$AlignableTableHeaderRenderer" ); if( paintBorders ) paintColumnBorders( g, c ); 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 37b069bf..6261d273 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -22,6 +22,7 @@ CheckBoxMenuItemUI=com.formdev.flatlaf.ui.FlatCheckBoxMenuItemUI ColorChooserUI=com.formdev.flatlaf.ui.FlatColorChooserUI ComboBoxUI=com.formdev.flatlaf.ui.FlatComboBoxUI EditorPaneUI=com.formdev.flatlaf.ui.FlatEditorPaneUI +FileChooserUI=com.formdev.flatlaf.ui.FlatFileChooserUI FormattedTextFieldUI=com.formdev.flatlaf.ui.FlatFormattedTextFieldUI LabelUI=com.formdev.flatlaf.ui.FlatLabelUI ListUI=com.formdev.flatlaf.ui.FlatListUI @@ -338,7 +339,7 @@ Table.selectionInactiveForeground=@selectionInactiveForeground #---- TableHeader ---- TableHeader.height=25 -TableHeader.cellBorder=2,2,2,2 +TableHeader.cellBorder=2,3,2,3 #---- TextArea ----