mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-10 22:17:13 -06:00
UI defaults: replaced "base" Metal LaF with BasicLookAndFeel (on Windows and Linux)
(UI defaults dumps did not change, so UI defaults are equal to Metal defaults)
This commit is contained in:
@@ -49,7 +49,6 @@ import javax.swing.UnsupportedLookAndFeelException;
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
import javax.swing.plaf.basic.BasicLookAndFeel;
|
||||
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
import com.formdev.flatlaf.util.SystemInfo;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
@@ -115,7 +114,10 @@ public abstract class FlatLaf
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
getBase().initialize();
|
||||
initBase();
|
||||
|
||||
if( base != null )
|
||||
base.initialize();
|
||||
|
||||
super.initialize();
|
||||
|
||||
@@ -200,34 +202,33 @@ public abstract class FlatLaf
|
||||
}
|
||||
|
||||
/**
|
||||
* Get/create base LaF. This is used to grab base UI defaults from different LaFs.
|
||||
* E.g. on Mac from system dependent LaF, otherwise from Metal LaF.
|
||||
* Create base LaF. This is used to grab base UI defaults from different LaFs.
|
||||
* On Mac from Aqua LaF, otherwise from Basic LaF.
|
||||
*/
|
||||
private BasicLookAndFeel getBase() {
|
||||
if( base == null ) {
|
||||
if( SystemInfo.IS_MAC ) {
|
||||
// use Mac Aqua LaF as base
|
||||
String aquaLafClassName = "com.apple.laf.AquaLookAndFeel";
|
||||
try {
|
||||
if( SystemInfo.IS_JAVA_9_OR_LATER ) {
|
||||
Method m = UIManager.class.getMethod( "createLookAndFeel", String.class );
|
||||
base = (BasicLookAndFeel) m.invoke( null, "Mac OS X" );
|
||||
} else
|
||||
base = (BasicLookAndFeel) Class.forName( aquaLafClassName ).newInstance();
|
||||
} catch( Exception ex ) {
|
||||
LOG.log( Level.SEVERE, "FlatLaf: Failed to initialize base look and feel '" + aquaLafClassName + "'.", ex );
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
} else
|
||||
base = new MetalLookAndFeel();
|
||||
private void initBase() {
|
||||
if( SystemInfo.IS_MAC && base == null ) {
|
||||
// use Mac Aqua LaF as base
|
||||
String aquaLafClassName = "com.apple.laf.AquaLookAndFeel";
|
||||
try {
|
||||
if( SystemInfo.IS_JAVA_9_OR_LATER ) {
|
||||
Method m = UIManager.class.getMethod( "createLookAndFeel", String.class );
|
||||
base = (BasicLookAndFeel) m.invoke( null, "Mac OS X" );
|
||||
} else
|
||||
base = (BasicLookAndFeel) Class.forName( aquaLafClassName ).newInstance();
|
||||
} catch( Exception ex ) {
|
||||
LOG.log( Level.SEVERE, "FlatLaf: Failed to initialize base look and feel '" + aquaLafClassName + "'.", ex );
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UIDefaults getDefaults() {
|
||||
UIDefaults defaults = getBase().getDefaults();
|
||||
UIDefaultsRemover.removeDefaults( defaults );
|
||||
initBase();
|
||||
|
||||
UIDefaults defaults = (base != null) ? base.getDefaults() : super.getDefaults();
|
||||
if( base != null )
|
||||
UIDefaultsRemover.removeDefaults( defaults );
|
||||
|
||||
// add Metal resource bundle, which is required for FlatFileChooserUI
|
||||
defaults.addResourceBundle( "com.sun.swing.internal.plaf.metal.resources.metal" );
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
|
||||
package com.formdev.flatlaf;
|
||||
|
||||
import java.util.Iterator;
|
||||
import javax.swing.UIDefaults;
|
||||
|
||||
/**
|
||||
* Removes UI defaults that are defined in "base" LaF (Metal or Aqua), but not used in FlatLaf.
|
||||
* Removes UI defaults that are defined in "base" LaF (Aqua), but not used in FlatLaf.
|
||||
*
|
||||
* This is a temporary class that can be removed when dropping "base" LaF.
|
||||
*
|
||||
@@ -29,88 +28,11 @@ import javax.swing.UIDefaults;
|
||||
class UIDefaultsRemover
|
||||
{
|
||||
static final String[] REMOVE_KEYS = {
|
||||
"AuditoryCues.defaultCueList",
|
||||
|
||||
"Button.disabledToolBarBorderBackground",
|
||||
"Button.focus",
|
||||
"Button.rolloverIconType",
|
||||
"Button.select",
|
||||
"Button.toolBarBorderBackground",
|
||||
|
||||
"CheckBox.focus",
|
||||
"CheckBox.select",
|
||||
"Checkbox.select", // this is a typo in MetalLookAndFeel
|
||||
"CheckBox.totalInsets",
|
||||
|
||||
"DesktopIcon.font",
|
||||
"DesktopIcon.width",
|
||||
|
||||
"InternalFrame.activeTitleGradient",
|
||||
"InternalFrame.optionDialogBorder",
|
||||
"InternalFrame.paletteBorder",
|
||||
"InternalFrame.paletteCloseIcon",
|
||||
"InternalFrame.paletteTitleHeight",
|
||||
|
||||
"Menu.checkIcon",
|
||||
|
||||
"MenuItem.checkIcon",
|
||||
|
||||
"OptionPane.errorDialog.border.background",
|
||||
"OptionPane.errorDialog.titlePane.background",
|
||||
"OptionPane.errorDialog.titlePane.foreground",
|
||||
"OptionPane.errorDialog.titlePane.shadow",
|
||||
"OptionPane.questionDialog.border.background",
|
||||
"OptionPane.questionDialog.titlePane.background",
|
||||
"OptionPane.questionDialog.titlePane.foreground",
|
||||
"OptionPane.questionDialog.titlePane.shadow",
|
||||
"OptionPane.warningDialog.border.background",
|
||||
"OptionPane.warningDialog.titlePane.background",
|
||||
"OptionPane.warningDialog.titlePane.foreground",
|
||||
"OptionPane.warningDialog.titlePane.shadow",
|
||||
|
||||
"RadioButton.focus",
|
||||
"RadioButton.select",
|
||||
"RadioButton.totalInsets",
|
||||
|
||||
"RootPane.colorChooserDialogBorder",
|
||||
"RootPane.errorDialogBorder",
|
||||
"RootPane.fileChooserDialogBorder",
|
||||
"RootPane.frameBorder",
|
||||
"RootPane.informationDialogBorder",
|
||||
"RootPane.plainDialogBorder",
|
||||
"RootPane.questionDialogBorder",
|
||||
"RootPane.warningDialogBorder",
|
||||
|
||||
"ScrollBar.darkShadow",
|
||||
"ScrollBar.highlight",
|
||||
"ScrollBar.shadow",
|
||||
|
||||
"Slider.altTrackColor",
|
||||
"Slider.focusGradient",
|
||||
"Slider.horizontalThumbIcon",
|
||||
"Slider.majorTickLength",
|
||||
"Slider.verticalThumbIcon",
|
||||
|
||||
"Spinner.arrowButtonBorder",
|
||||
"Spinner.arrowButtonInsets",
|
||||
|
||||
"SplitPane.dividerFocusColor",
|
||||
"SplitPane.oneTouchButtonsOpaque",
|
||||
|
||||
"TabbedPane.borderHightlightColor",
|
||||
"TabbedPane.unselectedBackground",
|
||||
"TabbedPane.tabAreaBackground",
|
||||
"TabbedPane.selectHighlight",
|
||||
"TabbedPane.selected",
|
||||
|
||||
"ToggleButton.focus",
|
||||
"ToggleButton.select",
|
||||
|
||||
"ToolBar.borderColor",
|
||||
"ToolBar.nonrolloverBorder",
|
||||
"ToolBar.rolloverBorder",
|
||||
|
||||
"ToolTip.hideAccelerator",
|
||||
|
||||
"Tree.line",
|
||||
};
|
||||
@@ -119,6 +41,7 @@ class UIDefaultsRemover
|
||||
for( String key : REMOVE_KEYS )
|
||||
defaults.remove( key );
|
||||
|
||||
/*
|
||||
Iterator<Object> itr = defaults.keySet().iterator();
|
||||
while( itr.hasNext() ) {
|
||||
Object key = itr.next();
|
||||
@@ -129,5 +52,6 @@ class UIDefaultsRemover
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,6 +286,7 @@ List.dropLineColor=@dropLineColor
|
||||
|
||||
Menu.border=com.formdev.flatlaf.ui.FlatMenuItemBorder
|
||||
Menu.arrowIcon=com.formdev.flatlaf.icons.FlatMenuArrowIcon
|
||||
Menu.checkIcon=null
|
||||
Menu.margin=@menuItemMargin
|
||||
Menu.submenuPopupOffsetX={scaledInteger}-4
|
||||
Menu.submenuPopupOffsetY={scaledInteger}-4
|
||||
@@ -305,6 +306,7 @@ MenuBar.itemMargins=3,3,3,3
|
||||
|
||||
MenuItem.border=com.formdev.flatlaf.ui.FlatMenuItemBorder
|
||||
MenuItem.arrowIcon=com.formdev.flatlaf.icons.FlatMenuItemArrowIcon
|
||||
MenuItem.checkIcon=null
|
||||
MenuItem.margin=@menuItemMargin
|
||||
MenuItem.opaque=false
|
||||
MenuItem.borderPainted=true
|
||||
|
||||
Reference in New Issue
Block a user