Revision: 4894 http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4894&view=rev Author: bphinz Date: 2012-04-25 03:24:37 +0000 (Wed, 25 Apr 2012) Log Message: ----------- Set Nimbus as the default look and feel if it's available, otherwise fallback to the native LAF. Allow LAF to be specified with swing.defaultlaf system property.
Modified Paths: -------------- trunk/java/com/tigervnc/vncviewer/VncViewer.java Modified: trunk/java/com/tigervnc/vncviewer/VncViewer.java =================================================================== --- trunk/java/com/tigervnc/vncviewer/VncViewer.java 2012-04-25 01:15:36 UTC (rev 4893) +++ trunk/java/com/tigervnc/vncviewer/VncViewer.java 2012-04-25 03:24:37 UTC (rev 4894) @@ -44,6 +44,7 @@ import java.util.Iterator; import javax.swing.*; import javax.swing.plaf.FontUIResource; +import javax.swing.UIManager.*; import com.tigervnc.rdr.*; import com.tigervnc.rfb.*; @@ -64,14 +65,21 @@ public static void setLookAndFeel() { try { - String nativeLaf = UIManager.getSystemLookAndFeelClassName(); - if (nativeLaf.endsWith("WindowsLookAndFeel")) - UIManager.setLookAndFeel(nativeLaf); + // Use Nimbus LookAndFeel if it's available, otherwise fallback + // to the native laf, or Metal if no native laf is available. + String laf = System.getProperty("swing.defaultlaf"); + if (laf == null) { + LookAndFeelInfo[] installedLafs = UIManager.getInstalledLookAndFeels(); + for (int i = 0; i < installedLafs.length; i++) { + if (installedLafs[i].getName().equals("Nimbus")) + laf = installedLafs[i].getClassName(); + } + if (laf == null) + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } + UIManager.setLookAndFeel(laf); UIManager.put("TitledBorder.titleColor",Color.blue); - LookAndFeel laf = UIManager.getLookAndFeel(); - if (laf == null) - return; - if (laf.getName().equals("Metal")) { + if (UIManager.getLookAndFeel().getName().equals("Metal")) { UIManager.put("swing.boldMetal", Boolean.FALSE); FontUIResource f = new FontUIResource("SansSerif", Font.PLAIN, 11); java.util.Enumeration keys = UIManager.getDefaults().keys(); @@ -81,7 +89,7 @@ if (value instanceof javax.swing.plaf.FontUIResource) UIManager.put(key, f); } - } else if (laf.getName().equals("Nimbus")) { + } else if (UIManager.getLookAndFeel().getName().equals("Nimbus")) { FontUIResource f; String os = System.getProperty("os.name"); if (os.startsWith("Windows")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Tigervnc-commits mailing list Tigervnc-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tigervnc-commits