mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 15:27:16 -06:00
added default color palette for action icons and object icons (based on IntelliJ Platform colors)
and use color palette for file chooser icons (issue #5)
This commit is contained in:
@@ -38,6 +38,7 @@ import javax.swing.SwingUtilities;
|
|||||||
import javax.swing.UIDefaults;
|
import javax.swing.UIDefaults;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.UnsupportedLookAndFeelException;
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
|
import javax.swing.plaf.ColorUIResource;
|
||||||
import javax.swing.plaf.FontUIResource;
|
import javax.swing.plaf.FontUIResource;
|
||||||
import javax.swing.plaf.basic.BasicLookAndFeel;
|
import javax.swing.plaf.basic.BasicLookAndFeel;
|
||||||
import javax.swing.plaf.metal.MetalLookAndFeel;
|
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||||
@@ -192,6 +193,7 @@ public abstract class FlatLaf
|
|||||||
Object aquaMenuBarUI = useScreenMenuBar ? defaults.get( "MenuBarUI" ) : null;
|
Object aquaMenuBarUI = useScreenMenuBar ? defaults.get( "MenuBarUI" ) : null;
|
||||||
|
|
||||||
initFonts( defaults );
|
initFonts( defaults );
|
||||||
|
initColorPalette( defaults, isDark() );
|
||||||
|
|
||||||
// load defaults from properties
|
// load defaults from properties
|
||||||
List<Class<?>> lafClassesForDefaultsLoading = getLafClassesForDefaultsLoading();
|
List<Class<?>> lafClassesForDefaultsLoading = getLafClassesForDefaultsLoading();
|
||||||
@@ -247,6 +249,45 @@ public abstract class FlatLaf
|
|||||||
defaults.put( "MenuItem.acceleratorFont", uiFont );
|
defaults.put( "MenuItem.acceleratorFont", uiFont );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the default color palette for action icons and object icons to the given UIDefaults.
|
||||||
|
* <p>
|
||||||
|
* This method is public and static to allow using the color palette with
|
||||||
|
* other LaFs (e.g. Windows LaF). To do so invoke:
|
||||||
|
* {@code FlatLaf.initColorPalette( UIManager.getLookAndFeelDefaults(), false );}
|
||||||
|
* after
|
||||||
|
* {@code UIManager.setLookAndFeel( ... );}.
|
||||||
|
* <p>
|
||||||
|
* The colors are based on IntelliJ Platform
|
||||||
|
* <a href="https://jetbrains.design/intellij/principles/icons/#action-icons">Action icons</a>
|
||||||
|
* and
|
||||||
|
* <a href="https://jetbrains.design/intellij/principles/icons/#noun-icons">Noun icons</a>
|
||||||
|
*/
|
||||||
|
public static void initColorPalette( UIDefaults defaults, boolean dark ) {
|
||||||
|
// colors for actions
|
||||||
|
// see https://jetbrains.design/intellij/principles/icons/#action-icons
|
||||||
|
defaults.put( "Actions.Red", new ColorUIResource( !dark ? 0xDB5860 : 0xC75450 ) );
|
||||||
|
defaults.put( "Actions.Yellow", new ColorUIResource( !dark ? 0xEDA200 : 0xF0A732 ) );
|
||||||
|
defaults.put( "Actions.Green", new ColorUIResource( !dark ? 0x59A869 : 0x499C54 ) );
|
||||||
|
defaults.put( "Actions.Blue", new ColorUIResource( !dark ? 0x389FD6 : 0x3592C4 ) );
|
||||||
|
defaults.put( "Actions.Grey", new ColorUIResource( !dark ? 0x6E6E6E : 0xAFB1B3 ) );
|
||||||
|
defaults.put( "Actions.GreyInline", new ColorUIResource( !dark ? 0x7F8B91 : 0x7F8B91 ) );
|
||||||
|
|
||||||
|
// colors for objects
|
||||||
|
// see https://jetbrains.design/intellij/principles/icons/#noun-icons
|
||||||
|
defaults.put( "Objects.Grey", new ColorUIResource( 0x9AA7B0 ) );
|
||||||
|
defaults.put( "Objects.Blue", new ColorUIResource( 0x40B6E0 ) );
|
||||||
|
defaults.put( "Objects.Green", new ColorUIResource( 0x62B543 ) );
|
||||||
|
defaults.put( "Objects.Yellow", new ColorUIResource( 0xF4AF3D ) );
|
||||||
|
defaults.put( "Objects.YellowDark", new ColorUIResource( 0xD9A343 ) );
|
||||||
|
defaults.put( "Objects.Purple", new ColorUIResource( 0xB99BF8 ) );
|
||||||
|
defaults.put( "Objects.Pink", new ColorUIResource( 0xF98B9E ) );
|
||||||
|
defaults.put( "Objects.Red", new ColorUIResource( 0xF26522 ) );
|
||||||
|
defaults.put( "Objects.RedStatus", new ColorUIResource( 0xE05555 ) );
|
||||||
|
defaults.put( "Objects.GreenAndroid", new ColorUIResource( 0xA4C639 ) );
|
||||||
|
defaults.put( "Objects.BlackText", new ColorUIResource( 0x231F20 ) );
|
||||||
|
}
|
||||||
|
|
||||||
private static void reSetLookAndFeel() {
|
private static void reSetLookAndFeel() {
|
||||||
EventQueue.invokeLater( () -> {
|
EventQueue.invokeLater( () -> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import javax.swing.UIManager;
|
|||||||
/**
|
/**
|
||||||
* "details view" icon for {@link javax.swing.JFileChooser}.
|
* "details view" icon for {@link javax.swing.JFileChooser}.
|
||||||
*
|
*
|
||||||
* @uiDefault FileChooser.icon.detailsViewColor Color
|
* @uiDefault Actions.Grey Color
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
@@ -31,7 +31,7 @@ public class FlatFileChooserDetailsViewIcon
|
|||||||
extends FlatAbstractIcon
|
extends FlatAbstractIcon
|
||||||
{
|
{
|
||||||
public FlatFileChooserDetailsViewIcon() {
|
public FlatFileChooserDetailsViewIcon() {
|
||||||
super( 16, 16, UIManager.getColor( "FileChooser.icon.detailsViewColor" ) );
|
super( 16, 16, UIManager.getColor( "Actions.Grey" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
|
|||||||
/**
|
/**
|
||||||
* "home folder" icon for {@link javax.swing.JFileChooser}.
|
* "home folder" icon for {@link javax.swing.JFileChooser}.
|
||||||
*
|
*
|
||||||
* @uiDefault FileChooser.icon.homeFolderColor Color
|
* @uiDefault Actions.Grey Color
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
@@ -32,7 +32,7 @@ public class FlatFileChooserHomeFolderIcon
|
|||||||
extends FlatAbstractIcon
|
extends FlatAbstractIcon
|
||||||
{
|
{
|
||||||
public FlatFileChooserHomeFolderIcon() {
|
public FlatFileChooserHomeFolderIcon() {
|
||||||
super( 16, 16, UIManager.getColor( "FileChooser.icon.homeFolderColor" ) );
|
super( 16, 16, UIManager.getColor( "Actions.Grey" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import javax.swing.UIManager;
|
|||||||
/**
|
/**
|
||||||
* "list view" icon for {@link javax.swing.JFileChooser}.
|
* "list view" icon for {@link javax.swing.JFileChooser}.
|
||||||
*
|
*
|
||||||
* @uiDefault FileChooser.icon.listViewColor Color
|
* @uiDefault Actions.Grey Color
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
@@ -31,7 +31,7 @@ public class FlatFileChooserListViewIcon
|
|||||||
extends FlatAbstractIcon
|
extends FlatAbstractIcon
|
||||||
{
|
{
|
||||||
public FlatFileChooserListViewIcon() {
|
public FlatFileChooserListViewIcon() {
|
||||||
super( 16, 16, UIManager.getColor( "FileChooser.icon.listViewColor" ) );
|
super( 16, 16, UIManager.getColor( "Actions.Grey" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
|
|||||||
/**
|
/**
|
||||||
* "new folder" icon for {@link javax.swing.JFileChooser}.
|
* "new folder" icon for {@link javax.swing.JFileChooser}.
|
||||||
*
|
*
|
||||||
* @uiDefault FileChooser.icon.newFolderColor Color
|
* @uiDefault Actions.Grey Color
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
@@ -32,7 +32,7 @@ public class FlatFileChooserNewFolderIcon
|
|||||||
extends FlatAbstractIcon
|
extends FlatAbstractIcon
|
||||||
{
|
{
|
||||||
public FlatFileChooserNewFolderIcon() {
|
public FlatFileChooserNewFolderIcon() {
|
||||||
super( 16, 16, UIManager.getColor( "FileChooser.icon.newFolderColor" ) );
|
super( 16, 16, UIManager.getColor( "Actions.Grey" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.formdev.flatlaf.icons;
|
package com.formdev.flatlaf.icons;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
@@ -24,15 +25,18 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
|
|||||||
/**
|
/**
|
||||||
* "up folder" icon for {@link javax.swing.JFileChooser}.
|
* "up folder" icon for {@link javax.swing.JFileChooser}.
|
||||||
*
|
*
|
||||||
* @uiDefault FileChooser.icon.upFolderColor Color
|
* @uiDefault Actions.Grey Color
|
||||||
|
* @uiDefault Actions.Blue Color
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
public class FlatFileChooserUpFolderIcon
|
public class FlatFileChooserUpFolderIcon
|
||||||
extends FlatAbstractIcon
|
extends FlatAbstractIcon
|
||||||
{
|
{
|
||||||
|
private final Color blueColor = UIManager.getColor( "Actions.Blue" );
|
||||||
|
|
||||||
public FlatFileChooserUpFolderIcon() {
|
public FlatFileChooserUpFolderIcon() {
|
||||||
super( 16, 16, UIManager.getColor( "FileChooser.icon.upFolderColor" ) );
|
super( 16, 16, UIManager.getColor( "Actions.Grey" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -47,6 +51,8 @@ public class FlatFileChooserUpFolderIcon
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
g.fill( FlatUIUtils.createPath( 2,3, 5.5,3, 7,5, 9,5, 9,9, 13,9, 13,5, 14,5, 14,13, 2,13 ) );
|
g.fill( FlatUIUtils.createPath( 2,3, 5.5,3, 7,5, 9,5, 9,9, 13,9, 13,5, 14,5, 14,13, 2,13 ) );
|
||||||
|
|
||||||
|
g.setColor( blueColor );
|
||||||
g.fill( FlatUIUtils.createPath( 12,4, 12,8, 10,8, 10,4, 8,4, 11,1, 14,4, 12,4 ) );
|
g.fill( FlatUIUtils.createPath( 12,4, 12,8, 10,8, 10,4, 8,4, 11,1, 14,4, 12,4 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import javax.swing.UIManager;
|
|||||||
/**
|
/**
|
||||||
* "computer" icon for {@link javax.swing.JFileChooser}.
|
* "computer" icon for {@link javax.swing.JFileChooser}.
|
||||||
*
|
*
|
||||||
* @uiDefault FileView.icon.computerColor Color
|
* @uiDefault Objects.Grey Color
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
@@ -33,7 +33,7 @@ public class FlatFileViewComputerIcon
|
|||||||
extends FlatAbstractIcon
|
extends FlatAbstractIcon
|
||||||
{
|
{
|
||||||
public FlatFileViewComputerIcon() {
|
public FlatFileViewComputerIcon() {
|
||||||
super( 16, 16, UIManager.getColor( "FileView.icon.computerColor" ) );
|
super( 16, 16, UIManager.getColor( "Objects.Grey" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
|
|||||||
/**
|
/**
|
||||||
* "directory" icon for {@link javax.swing.JFileChooser}.
|
* "directory" icon for {@link javax.swing.JFileChooser}.
|
||||||
*
|
*
|
||||||
* @uiDefault FileView.icon.directoryColor Color
|
* @uiDefault Objects.Grey Color
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
@@ -32,7 +32,7 @@ public class FlatFileViewDirectoryIcon
|
|||||||
extends FlatAbstractIcon
|
extends FlatAbstractIcon
|
||||||
{
|
{
|
||||||
public FlatFileViewDirectoryIcon() {
|
public FlatFileViewDirectoryIcon() {
|
||||||
super( 16, 16, UIManager.getColor( "FileView.icon.directoryColor" ) );
|
super( 16, 16, UIManager.getColor( "Objects.Grey" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
|
|||||||
/**
|
/**
|
||||||
* "file" icon for {@link javax.swing.JFileChooser}.
|
* "file" icon for {@link javax.swing.JFileChooser}.
|
||||||
*
|
*
|
||||||
* @uiDefault FileView.icon.fileColor Color
|
* @uiDefault Objects.Grey Color
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
@@ -32,7 +32,7 @@ public class FlatFileViewFileIcon
|
|||||||
extends FlatAbstractIcon
|
extends FlatAbstractIcon
|
||||||
{
|
{
|
||||||
public FlatFileViewFileIcon() {
|
public FlatFileViewFileIcon() {
|
||||||
super( 16, 16, UIManager.getColor( "FileView.icon.fileColor" ) );
|
super( 16, 16, UIManager.getColor( "Objects.Grey" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
|
|||||||
/**
|
/**
|
||||||
* "floppy drive" icon for {@link javax.swing.JFileChooser}.
|
* "floppy drive" icon for {@link javax.swing.JFileChooser}.
|
||||||
*
|
*
|
||||||
* @uiDefault FileView.icon.floppyDriveColor Color
|
* @uiDefault Objects.Grey Color
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
@@ -33,7 +33,7 @@ public class FlatFileViewFloppyDriveIcon
|
|||||||
extends FlatAbstractIcon
|
extends FlatAbstractIcon
|
||||||
{
|
{
|
||||||
public FlatFileViewFloppyDriveIcon() {
|
public FlatFileViewFloppyDriveIcon() {
|
||||||
super( 16, 16, UIManager.getColor( "FileView.icon.floppyDriveColor" ) );
|
super( 16, 16, UIManager.getColor( "Objects.Grey" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import javax.swing.UIManager;
|
|||||||
/**
|
/**
|
||||||
* "hard drive" icon for {@link javax.swing.JFileChooser}.
|
* "hard drive" icon for {@link javax.swing.JFileChooser}.
|
||||||
*
|
*
|
||||||
* @uiDefault FileView.icon.hardDriveColor Color
|
* @uiDefault Objects.Grey Color
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
@@ -33,7 +33,7 @@ public class FlatFileViewHardDriveIcon
|
|||||||
extends FlatAbstractIcon
|
extends FlatAbstractIcon
|
||||||
{
|
{
|
||||||
public FlatFileViewHardDriveIcon() {
|
public FlatFileViewHardDriveIcon() {
|
||||||
super( 16, 16, UIManager.getColor( "FileView.icon.hardDriveColor" ) );
|
super( 16, 16, UIManager.getColor( "Objects.Grey" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -128,12 +128,6 @@ FileChooser.homeFolderIcon=com.formdev.flatlaf.icons.FlatFileChooserHomeFolderIc
|
|||||||
FileChooser.detailsViewIcon=com.formdev.flatlaf.icons.FlatFileChooserDetailsViewIcon
|
FileChooser.detailsViewIcon=com.formdev.flatlaf.icons.FlatFileChooserDetailsViewIcon
|
||||||
FileChooser.listViewIcon=com.formdev.flatlaf.icons.FlatFileChooserListViewIcon
|
FileChooser.listViewIcon=com.formdev.flatlaf.icons.FlatFileChooserListViewIcon
|
||||||
|
|
||||||
FileChooser.icon.newFolderColor=@icon
|
|
||||||
FileChooser.icon.upFolderColor=@icon
|
|
||||||
FileChooser.icon.homeFolderColor=@icon
|
|
||||||
FileChooser.icon.detailsViewColor=@icon
|
|
||||||
FileChooser.icon.listViewColor=@icon
|
|
||||||
|
|
||||||
|
|
||||||
#---- FileView ----
|
#---- FileView ----
|
||||||
|
|
||||||
@@ -143,12 +137,6 @@ FileView.computerIcon=com.formdev.flatlaf.icons.FlatFileViewComputerIcon
|
|||||||
FileView.hardDriveIcon=com.formdev.flatlaf.icons.FlatFileViewHardDriveIcon
|
FileView.hardDriveIcon=com.formdev.flatlaf.icons.FlatFileViewHardDriveIcon
|
||||||
FileView.floppyDriveIcon=com.formdev.flatlaf.icons.FlatFileViewFloppyDriveIcon
|
FileView.floppyDriveIcon=com.formdev.flatlaf.icons.FlatFileViewFloppyDriveIcon
|
||||||
|
|
||||||
FileView.icon.directoryColor=@icon
|
|
||||||
FileView.icon.fileColor=@icon
|
|
||||||
FileView.icon.computerColor=@icon
|
|
||||||
FileView.icon.hardDriveColor=@icon
|
|
||||||
FileView.icon.floppyDriveColor=@icon
|
|
||||||
|
|
||||||
|
|
||||||
#---- FormattedTextField ----
|
#---- FormattedTextField ----
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user