2014-07-14 20:03:25|?次阅读|上传:wustguangh【已有?条评论】发表评论
关键词:Java, Swing, 界面设计|来源:唯设编程网
Swing开发实现不同显示风格切换(换肤)的方法这篇文章已经介绍了Java使用Swing开发用户界面时实现显示风格切换(换肤)的方法,里面提到了使用javax.swing.UIManager类的静态成员函数setLookAndFeel即可以方便实现不同显示风格切换,该函数需要一个字符串类型的显示风格类名,本文介绍Swing开发用户界面时常用的显示风格对应的类名,供大家参考。
private static Map<String, String> substanceItems = new HashMap<String, String>(); static { substanceItems.put("BusinessLookAndFeel", "org.jvnet.substance.skin.SubstanceBusinessLookAndFeel"); substanceItems.put("BusinessBlueSteelLookAndFeel", "org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel"); substanceItems.put("BusinessBlackSteelLookAndFeel", "org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel"); substanceItems.put("CremeLookAndFeel", "org.jvnet.substance.skin.SubstanceCremeLookAndFeel"); substanceItems.put("CremeCoffeeLookAndFeel", "org.jvnet.substance.skin.SubstanceCremeCoffeeLookAndFeel"); substanceItems.put("SaharaLookAndFeel", "org.jvnet.substance.skin.SubstanceSaharaLookAndFeel"); substanceItems.put("ModerateLookAndFeel", "org.jvnet.substance.skin.SubstanceModerateLookAndFeel"); substanceItems.put("OfficeSilver2007LookAndFeel", "org.jvnet.substance.skin.SubstanceOfficeSilver2007LookAndFeel"); substanceItems.put("OfficeBlue2007LookAndFeel", "org.jvnet.substance.skin.SubstanceOfficeBlue2007LookAndFeel"); substanceItems.put("NebulaBrickWallLookAndFeel", "org.jvnet.substance.skin.SubstanceNebulaBrickWallLookAndFeel"); substanceItems.put("AutumnLookAndFeel", "org.jvnet.substance.skin.SubstanceAutumnLookAndFeel"); substanceItems.put("MistSilverLookAndFeel", "org.jvnet.substance.skin.SubstanceMistSilverLookAndFeel"); substanceItems.put("MistAquaLookAndFeel", "org.jvnet.substance.skin.SubstanceMistAquaLookAndFeel"); substanceItems.put("DustLookAndFeel", "org.jvnet.substance.skin.SubstanceDustLookAndFeel"); substanceItems.put("DustCoffeeLookAndFeel", "org.jvnet.substance.skin.SubstanceDustCoffeeLookAndFeel"); substanceItems.put("GeminiLookAndFeel", "org.jvnet.substance.api.skin.SubstanceGeminiLookAndFeel"); }
private static Map<String, String> swingItems = new HashMap<String, String>(); static { swingItems.put("MetalLookAndFeel","javax.swing.plaf.metal.MetalLookAndFeel"); swingItems.put("WindowsLookAndFeel","com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); swingItems.put("WindowsClassicLookAndFeel","com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"); swingItems.put("MotifLookAndFeel","com.sun.java.swing.plaf.motif.MotifLookAndFeel"); swingItems.put("NimbusLookAndFeel","com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); swingItems.put("MacLookAndFeel(need OS surport)","com.sun.java.swing.plaf.mac.MacLookAndFeel"); swingItems.put("GTKLookAndFeel(need OS surport)","com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); swingItems.put("SystemLookAndFeel",UIManager.getSystemLookAndFeelClassName()); swingItems.put("CrossPlatformLookAndFeel",UIManager.getCrossPlatformLookAndFeelClassName()); }
private static Map<String, String> JTattooItems = new HashMap<String, String>(); static { JTattooItems.put("NoireLookAndFeel","com.jtattoo.plaf.noire.NoireLookAndFeel");//柔和黑 JTattooItems.put("SmartLookAndFeel","com.jtattoo.plaf.smart.SmartLookAndFeel");//木质感+xp风格 JTattooItems.put("MintLookAndFeel","com.jtattoo.plaf.mint.MintLookAndFeel");//椭圆按钮+黄色按钮背景 JTattooItems.put("McWinLookAndFeel","com.jtattoo.plaf.mcwin.McWinLookAndFeel");//椭圆按钮+绿色按钮背景 JTattooItems.put("LunaLookAndFeel","com.jtattoo.plaf.luna.LunaLookAndFeel");//纯XP风格 JTattooItems.put("HiFiLookAndFeel","com.jtattoo.plaf.hifi.HiFiLookAndFeel");//黑色风格 JTattooItems.put("FastLookAndFeel","com.jtattoo.plaf.fast.FastLookAndFeel");//普通swing风格+蓝色边框 JTattooItems.put("BernsteinLookAndFeel","com.jtattoo.plaf.bernstein.BernsteinLookAndFeel");//黄色风格 JTattooItems.put("AluminiumLookAndFeel","com.jtattoo.plaf.aluminium.AluminiumLookAndFeel");//椭圆按钮+翠绿色按钮背景+金属质感 JTattooItems.put("AeroLookAndFeel","com.jtattoo.plaf.aero.AeroLookAndFeel");//xp清新风格 JTattooItems.put("AcrylLookAndFeel","com.jtattoo.plaf.acryl.AcrylLookAndFeel");//布质感+swing纯风格 }
private static Map<String, String> otherItems = new HashMap<String, String>(); static { otherItems.put("NapkinLookAndFeel", "napkin.NapkinLookAndFeel"); otherItems.put("OfficeXPLookAndFeel", "org.fife.plaf.OfficeXP.OfficeXPLookAndFeel"); otherItems.put("VisualStudio2005LookAndFeel", "org.fife.plaf.VisualStudio2005.VisualStudio2005LookAndFeel"); otherItems.put("3DLookAndFeel", "de.hillenbrand.swing.plaf.threeD.ThreeDLookAndFeel"); otherItems.put("PgsLookAndFeel", "com.pagosoft.plaf.PgsLookAndFeel"); otherItems.put("NimRODLookAndFeel", "com.nilo.plaf.nimrod.NimRODLookAndFeel"); }
为了方便使用,通常我们可以将它们存在HashMap中,这样我们可以给每一种显示风格对应类名取一个直观的名字。