public class SWingUtil {
public static Map<String, String> themeMap;
static {
//主题名 - className
themeMap = new LinkedHashMap<>();
//swing默认主题
themeMap.put("Metal","javax.swing.plaf.metal.MetalLookAndFeel");
themeMap.put("Windows","com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
themeMap.put("Windows Classic","com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel");
themeMap.put("Motif","com.sun.java.swing.plaf.motif.MotifLookAndFeel");
themeMap.put("当前系统",UIManager.getSystemLookAndFeelClassName());
themeMap.put("Flat Light(默认)","com.formdev.flatlaf.FlatLightLaf");
themeMap.put("Flat dark","com.formdev.flatlaf.FlatDarkLaf");
themeMap.put("Flat IntelliJ","com.formdev.flatlaf.FlatIntelliJLaf");
themeMap.put("Flat Darcula","com.formdev.flatlaf.FlatDarculaLaf");
// http://www.jtattoo.net/index.html
themeMap.put("Tattoo01","com.jtattoo.plaf.acryl.AcrylLookAndFeel");
themeMap.put("Tattoo02","com.jtattoo.plaf.aero.AeroLookAndFeel");
themeMap.put("Tattoo03","com.jtattoo.plaf.aluminium.AluminiumLookAndFeel");
themeMap.put("Tattoo04","com.jtattoo.plaf.bernstein.BernsteinLookAndFeel");
themeMap.put("Tattoo05","com.jtattoo.plaf.fast.FastLookAndFeel");
themeMap.put("Tattoo06","com.jtattoo.plaf.hifi.HiFiLookAndFeel");
themeMap.put("Tattoo07","com.jtattoo.plaf.mcwin.McWinLookAndFeel");
themeMap.put("Tattoo08","com.jtattoo.plaf.mint.MintLookAndFeel");
themeMap.put("Tattoo09","com.jtattoo.plaf.noire.NoireLookAndFeel");
themeMap.put("Tattoo10","com.jtattoo.plaf.smart.SmartLookAndFeel");
themeMap.put("Tattoo11","com.jtattoo.plaf.luna.LunaLookAndFeel");
themeMap.put("Tattoo12","com.jtattoo.plaf.texture.TextureLookAndFeel");
}
public static void UnifiedStyle(){
try {
String lookAndFeel = getLookAndFeel(18);
UIManager.setLookAndFeel(lookAndFeel);
UIManager.put("TableHeader.font",new Font("微软雅黑", Font.PLAIN, 20));
UIManager.put("InternalFrame.titleFont",new Font("微软雅黑", Font.PLAIN, 15));
} catch (Exception e) {
e.printStackTrace();
}
}
public static String getLookAndFeel(int index){
int i = 0;
for (String value : themeMap.values()) {
if (i == index){
return value;
}
i++;
}
return null;
}
public static void main(String[] args) {
// FontUIResource fontRes = new FontUIResource(font);
Enumeration<Object> keys = UIManager.getDefaults().keys();
while (keys.hasMoreElements()){
Object key = keys.nextElement();
Object value = UIManager.get(key);
// if (value instanceof FontUIResource) {
// UIManager.put(value,font);
// System.out.println(key);
// }
System.out.println(key);
}
}
}
08-06
3818
