mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 07:17:13 -06:00
FileChooser: use system icons (issue #100)
This commit is contained in:
@@ -16,6 +16,7 @@ FlatLaf Change Log
|
|||||||
`flatlaf-swingx-<version>.jar`.
|
`flatlaf-swingx-<version>.jar`.
|
||||||
- CheckBox and RadioButton: Flag `opaque` is no longer ignored when checkbox or
|
- CheckBox and RadioButton: Flag `opaque` is no longer ignored when checkbox or
|
||||||
radio button is used as table cell renderer. (issue #77)
|
radio button is used as table cell renderer. (issue #77)
|
||||||
|
- FileChooser: Use system icons. (issue #100)
|
||||||
- FileChooser: Fixed missing labels in file chooser when running on Java 9 or
|
- FileChooser: Fixed missing labels in file chooser when running on Java 9 or
|
||||||
later. (issue #98)
|
later. (issue #98)
|
||||||
- PasswordField: Do not apply minimum width if `columns` property is greater
|
- PasswordField: Do not apply minimum width if `columns` property is greater
|
||||||
|
|||||||
@@ -17,8 +17,11 @@
|
|||||||
package com.formdev.flatlaf.ui;
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.io.File;
|
||||||
|
import javax.swing.Icon;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.filechooser.FileView;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.metal.MetalFileChooserUI;
|
import javax.swing.plaf.metal.MetalFileChooserUI;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
@@ -117,6 +120,8 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
public class FlatFileChooserUI
|
public class FlatFileChooserUI
|
||||||
extends MetalFileChooserUI
|
extends MetalFileChooserUI
|
||||||
{
|
{
|
||||||
|
private final FlatFileView fileView = new FlatFileView();
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
return new FlatFileChooserUI( (JFileChooser) c );
|
return new FlatFileChooserUI( (JFileChooser) c );
|
||||||
}
|
}
|
||||||
@@ -134,4 +139,37 @@ public class FlatFileChooserUI
|
|||||||
public Dimension getMinimumSize( JComponent c ) {
|
public Dimension getMinimumSize( JComponent c ) {
|
||||||
return UIScale.scale( super.getMinimumSize( c ) );
|
return UIScale.scale( super.getMinimumSize( c ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FileView getFileView( JFileChooser fc ) {
|
||||||
|
return fileView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearIconCache() {
|
||||||
|
fileView.clearIconCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---- class FlatFileView -------------------------------------------------
|
||||||
|
|
||||||
|
private class FlatFileView
|
||||||
|
extends BasicFileView
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Icon getIcon( File f ) {
|
||||||
|
Icon icon = getCachedIcon( f );
|
||||||
|
if( icon != null )
|
||||||
|
return icon;
|
||||||
|
|
||||||
|
if( f != null ) {
|
||||||
|
icon = getFileChooser().getFileSystemView().getSystemIcon( f );
|
||||||
|
if( icon != null ) {
|
||||||
|
cacheIcon( f, icon );
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getIcon( f );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user