summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorBrian Hinz <bphinz@users.sourceforge.net>2012-04-25 03:24:37 +0000
committerBrian Hinz <bphinz@users.sourceforge.net>2012-04-25 03:24:37 +0000
commite4363d65dd3cc8f01ec974713f3ecb0702548d31 (patch)
tree7e577215561cec6b85fef686938c88a920ab982a /java
parentcbd52d707b6ce80b011a434e21ebf95b1e838af2 (diff)
downloadtigervnc-e4363d65dd3cc8f01ec974713f3ecb0702548d31.tar.gz
tigervnc-e4363d65dd3cc8f01ec974713f3ecb0702548d31.zip
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.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4894 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java')
-rw-r--r--java/com/tigervnc/vncviewer/VncViewer.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/java/com/tigervnc/vncviewer/VncViewer.java b/java/com/tigervnc/vncviewer/VncViewer.java
index a5d15cec..26f41b62 100644
--- a/java/com/tigervnc/vncviewer/VncViewer.java
+++ b/java/com/tigervnc/vncviewer/VncViewer.java
@@ -44,6 +44,7 @@ import java.util.ArrayList;
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 class VncViewer extends java.applet.Applet implements Runnable
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 @@ public class VncViewer extends java.applet.Applet implements Runnable
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")) {