Java源码示例:com.formdev.flatlaf.FlatLightLaf
示例1
public static void main( String[] args ) {
File file = new File( args.length > 0
? args[0]
: "theme-editor-test.properties" ); // TODO
SwingUtilities.invokeLater( () -> {
FlatLightLaf.install();
FlatThemeFileEditor frame = new FlatThemeFileEditor();
try {
frame.themeEditorArea.load( FileLocation.create( file ) );
} catch( IOException ex ) {
ex.printStackTrace();
}
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
frame.setSize( Math.min( UIScale.scale( 800 ), screenSize.width ),
screenSize.height - UIScale.scale( 100 ) );
frame.setLocationRelativeTo( null );
frame.setVisible( true );
} );
}
示例2
private void applyTheme(String theme_) {
try {
if (theme_.equals("light")) {
UIManager.setLookAndFeel(new FlatLightLaf());
}
else if (theme_.equals("dark")) {
UIManager.setLookAndFeel(new FlatDarkLaf());
}
// Apply the new theme
FlatLaf.updateUI();
}
catch (UnsupportedLookAndFeelException e1) {
e1.printStackTrace();
}
}
示例3
/**
* Install L&Fs.
*/
public static void installLnfs() {
// Flat LaF
UIManager.installLookAndFeel("Flat Light", com.formdev.flatlaf.FlatLightLaf.class.getName());
UIManager.installLookAndFeel("Flat Dark", com.formdev.flatlaf.FlatDarkLaf.class.getName());
UIManager.installLookAndFeel("Flat IntelliJ", com.formdev.flatlaf.FlatIntelliJLaf.class.getName());
UIManager.installLookAndFeel("Flat Darcula", com.formdev.flatlaf.FlatDarculaLaf.class.getName());
// VAqua is optional
if (OperatingSystem.isMacOs() && isVAquaAvailable()) {
UIManager.installLookAndFeel("macOS (VAqua)", VAQUA_LAF_CLASS);
}
}
示例4
/**
* Use the appropriate look and feel for the current platform.
*
* @return Look and feel class name used
*/
public static String useLnfForPlatform() {
String lnfClassName = null;
if (OperatingSystem.isWindows()) {
lnfClassName = UIManager.getSystemLookAndFeelClassName();
} else if (OperatingSystem.isMacOs()) {
if (isVAquaAvailable()){
lnfClassName = VAQUA_LAF_CLASS;
} else {
lnfClassName = UIManager.getSystemLookAndFeelClassName();
}
} else {
String xdgCurrentDesktop = System.getenv("XDG_CURRENT_DESKTOP");
if ("Unity".equalsIgnoreCase(xdgCurrentDesktop)
|| "XFCE".equalsIgnoreCase(xdgCurrentDesktop)
|| "GNOME".equalsIgnoreCase(xdgCurrentDesktop)
|| "X-Cinnamon".equalsIgnoreCase(xdgCurrentDesktop)
|| "LXDE".equalsIgnoreCase(xdgCurrentDesktop)
) {
lnfClassName = UIManager.getSystemLookAndFeelClassName();
} else {
lnfClassName = FlatLightLaf.class.getName();
}
}
useLnf(lnfClassName);
return lnfClassName;
}
示例5
@Override
public void register(@Nonnull Consumer<UIManager.LookAndFeelInfo> consumer) {
consumer.accept(LookAndFeelInfoWithClassLoader.simple("Flat Laf - Light", FlatLightLaf.class));
consumer.accept(LookAndFeelInfoWithClassLoader.simple("Flat Laf - Dark", FlatDarkLaf.class));
consumer.accept(LookAndFeelInfoWithClassLoader.simple("Flat Laf - IntelliJ", FlatIntelliJLaf.class));
consumer.accept(LookAndFeelInfoWithClassLoader.simple("Flat Laf - Darcula", FlatDarculaLaf.class));
}
示例6
@Override
public void validate() throws IllegalStateException {
UIManager.installLookAndFeel(new UIManager.LookAndFeelInfo(Bundle.LBL_FLATLAF_LIGHT(), FlatLightLaf.class.getName()));
UIManager.installLookAndFeel(new UIManager.LookAndFeelInfo(Bundle.LBL_FLATLAF_DARK(), FlatDarkLaf.class.getName()));
}