Revision: 4893
          http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4893&view=rev
Author:   bphinz
Date:     2012-04-25 01:15:36 +0000 (Wed, 25 Apr 2012)
Log Message:
-----------
UI tweaks to improve look & feel consistency.

Modified Paths:
--------------
    trunk/java/com/tigervnc/vncviewer/OptionsDialog.java
    trunk/java/com/tigervnc/vncviewer/ServerDialog.java
    trunk/java/com/tigervnc/vncviewer/VncViewer.java

Modified: trunk/java/com/tigervnc/vncviewer/OptionsDialog.java
===================================================================
--- trunk/java/com/tigervnc/vncviewer/OptionsDialog.java        2012-04-21 
00:44:08 UTC (rev 4892)
+++ trunk/java/com/tigervnc/vncviewer/OptionsDialog.java        2012-04-25 
01:15:36 UTC (rev 4893)
@@ -84,27 +84,28 @@
     customCompressLevel.addItemListener(this);
     Object[] compressionLevels = { 1, 2, 3, 4, 5, 6 };
     compressLevel  = new JComboBox(compressionLevels);
-    compressLevel.setEditable(true);
     JLabel compressionLabel = new JLabel("Level (1=fast, 6=best [4-6 are 
rarely useful])");
     noJpeg = new JCheckBox("Allow JPEG Compression");
     noJpeg.addItemListener(this);
     Object[] qualityLevels = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
     qualityLevel  = new JComboBox(qualityLevels);
     JLabel qualityLabel = new JLabel("Level (0=poor, 9=best)");
-    compressLevel.setPreferredSize(qualityLevel.getPreferredSize());
     // Hack to set the left inset on editable JComboBox
     if (UIManager.getLookAndFeel().getID() == "Windows") {
       
compressLevel.setBorder(BorderFactory.createCompoundBorder(compressLevel.getBorder(),
         BorderFactory.createEmptyBorder(0,1,0,0)));
-    } else {
+    } else if (UIManager.getLookAndFeel().getID() == "Metal") {
       ComboBoxEditor editor = compressLevel.getEditor();
       JTextField jtf = (JTextField)editor.getEditorComponent();
-      jtf.setBorder(new CompoundBorder(jtf.getBorder(), new 
EmptyBorder(0,1,0,0)));
+      jtf.setBorder(new CompoundBorder(jtf.getBorder(), new 
EmptyBorder(0,2,0,0)));
     }
-    addGBComponent(customCompressLevel, tightPanel, 0, 0, 2, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new 
Insets(0,2,0,0));
+    Dimension size = compressLevel.getPreferredSize();
+    compressLevel.setEditable(true);
+    compressLevel.setPreferredSize(size);
+    addGBComponent(customCompressLevel, tightPanel, 0, 0, 2, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new 
Insets(0,0,0,0));
     addGBComponent(compressLevel, tightPanel,       0, 1, 1, 1, 2, 2, 0, 0, 
GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new 
Insets(0,20,0,0));
     addGBComponent(compressionLabel, tightPanel,    1, 1, 1, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(0,5,0,0));
-    addGBComponent(noJpeg, tightPanel,              0, 2, 2, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new 
Insets(0,2,0,0));
+    addGBComponent(noJpeg, tightPanel,              0, 2, 2, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new 
Insets(0,0,0,0));
     addGBComponent(qualityLevel, tightPanel,        0, 3, 1, 1, 2, 2, 0, 0, 
GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new 
Insets(0,20,0,0));
     addGBComponent(qualityLabel, tightPanel,        1, 3, 1, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(0,5,0,0));
 
@@ -116,10 +117,10 @@
     lowColour = addRadioCheckbox("Low (64 colours)", colourGroup, colourPanel);
     veryLowColour = addRadioCheckbox("Very low(8 colours)", colourGroup, 
colourPanel);
 
-    addGBComponent(autoSelect,FormatPanel,    0, 0, 2, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new 
Insets(0,2,0,0));
-    addGBComponent(encodingPanel,FormatPanel, 0, 1, 1, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(0,2,0,0));
-    addGBComponent(colourPanel,FormatPanel,   1, 1, 1, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_END, new 
Insets(0,2,0,0));
-    addGBComponent(tightPanel,FormatPanel,    0, 2, 2, 
GridBagConstraints.REMAINDER, 2, 2, 1, 1, GridBagConstraints.HORIZONTAL, 
GridBagConstraints.FIRST_LINE_START, new Insets(0,2,0,0));
+    addGBComponent(autoSelect,FormatPanel,    0, 0, 2, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new 
Insets(4,5,0,5));
+    addGBComponent(encodingPanel,FormatPanel, 0, 1, 1, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(0,10,0,5));
+    addGBComponent(colourPanel,FormatPanel,   1, 1, 1, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_END, new 
Insets(0,0,0,5));
+    addGBComponent(tightPanel,FormatPanel,    0, 2, 2, 
GridBagConstraints.REMAINDER, 2, 2, 1, 1, GridBagConstraints.HORIZONTAL, 
GridBagConstraints.FIRST_LINE_START, new Insets(0,5,0,5));
 
     // Inputs tab
     InputsPanel=new JPanel(new GridBagLayout());
@@ -135,11 +136,11 @@
       { "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", 
"F12" };
     menuKey  = new JComboBox(menuKeys);
     menuKey.addItemListener(this);
-    addGBComponent(viewOnly,InputsPanel,        0, 0, 2, 1, 0, 0, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(4,4,0,4));
-    addGBComponent(acceptClipboard,InputsPanel, 0, 1, 2, 1, 0, 0, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(4,4,0,4));
-    addGBComponent(sendClipboard,InputsPanel,   0, 2, 2, 1, 0, 0, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(4,4,0,4));
-    addGBComponent(menuKeyLabel,InputsPanel,    0, 3, 1, 
GridBagConstraints.REMAINDER, 0, 0, 1, 1, GridBagConstraints.NONE, 
GridBagConstraints.FIRST_LINE_START, new Insets(8,8,0,4));
-    addGBComponent(menuKey,InputsPanel,         1, 3, 1, 
GridBagConstraints.REMAINDER, 0, 0, 25, 1, GridBagConstraints.NONE, 
GridBagConstraints.FIRST_LINE_START, new Insets(4,4,0,4));
+    addGBComponent(viewOnly,InputsPanel,        0, 0, 2, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(4,5,0,5));
+    addGBComponent(acceptClipboard,InputsPanel, 0, 1, 2, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(4,5,0,5));
+    addGBComponent(sendClipboard,InputsPanel,   0, 2, 2, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(4,5,0,5));
+    addGBComponent(menuKeyLabel,InputsPanel,    0, 3, 1, 
GridBagConstraints.REMAINDER, 2, 2, 1, 1, GridBagConstraints.NONE, 
GridBagConstraints.FIRST_LINE_START, new Insets(8,8,0,5));
+    addGBComponent(menuKey,InputsPanel,         1, 3, 1, 
GridBagConstraints.REMAINDER, 2, 2, 25, 1, GridBagConstraints.NONE, 
GridBagConstraints.FIRST_LINE_START, new Insets(4,5,0,5));
 
     // Misc tab
     MiscPanel=new JPanel(new GridBagLayout());
@@ -157,14 +158,24 @@
       "Auto", "Fixed Aspect Ratio", "50%", "75%", "95%", "100%", "105%", 
       "125%", "150%", "175%", "200%", "250%", "300%", "350%", "400%" };
     scalingFactor = new JComboBox(scalingFactors);
+    // Hack to set the left inset on editable JComboBox
+    if (UIManager.getLookAndFeel().getID() == "Windows") {
+      
scalingFactor.setBorder(BorderFactory.createCompoundBorder(compressLevel.getBorder(),
+        BorderFactory.createEmptyBorder(0,1,0,0)));
+    } else if (UIManager.getLookAndFeel().getID() == "Metal") {
+      ComboBoxEditor sfe = scalingFactor.getEditor();
+      JTextField sfeTextField = (JTextField)sfe.getEditorComponent();
+      sfeTextField.setBorder(new CompoundBorder(sfeTextField.getBorder(), 
+                                                new EmptyBorder(0,2,0,0)));
+    }
     scalingFactor.setEditable(true);
     scalingFactor.addItemListener(this);
-    addGBComponent(fullScreen,MiscPanel,     0, 0, 2, 1, 0, 0, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(4,4,0,4));
-    addGBComponent(shared,MiscPanel,         0, 1, 2, 1, 0, 0, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(4,4,0,4));
-    addGBComponent(useLocalCursor,MiscPanel, 0, 2, 2, 1, 0, 0, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(4,4,0,4));
-    addGBComponent(acceptBell,MiscPanel,     0, 3, 2, 1, 0, 0, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new 
Insets(4,4,0,4));
-    addGBComponent(scalingFactorLabel,MiscPanel, 0, 4, 1, 
GridBagConstraints.REMAINDER, 0, 0, 1, 1, GridBagConstraints.NONE, 
GridBagConstraints.FIRST_LINE_START, new Insets(8,8,0,4));
-    addGBComponent(scalingFactor,MiscPanel, 1, 4, 1, 
GridBagConstraints.REMAINDER, 0, 0, 25, 1, GridBagConstraints.NONE, 
GridBagConstraints.FIRST_LINE_START, new Insets(4,4,0,4));
+    addGBComponent(fullScreen,MiscPanel,     0, 0, 2, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(4,5,0,5));
+    addGBComponent(shared,MiscPanel,         0, 1, 2, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(4,5,0,5));
+    addGBComponent(useLocalCursor,MiscPanel, 0, 2, 2, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(4,5,0,5));
+    addGBComponent(acceptBell,MiscPanel,     0, 3, 2, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new 
Insets(4,5,0,5));
+    addGBComponent(scalingFactorLabel,MiscPanel, 0, 4, 1, 
GridBagConstraints.REMAINDER, 2, 2, 1, 1, GridBagConstraints.NONE, 
GridBagConstraints.FIRST_LINE_START, new Insets(8,8,0,5));
+    addGBComponent(scalingFactor,MiscPanel, 1, 4, 1, 
GridBagConstraints.REMAINDER, 2, 2, 25, 1, GridBagConstraints.NONE, 
GridBagConstraints.FIRST_LINE_START, new Insets(4,5,0,5));
 
     // load/save tab
     DefaultsPanel=new JPanel(new GridBagLayout());
@@ -193,8 +204,8 @@
     defSaveButton.addActionListener(this);
     addGBComponent(defSaveButton,defaultsPanel, 0, 1, 1, 1, 0, 0, 0, 1, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(4,8,4,8));
 
-    addGBComponent(configPanel,DefaultsPanel, 0, 0, 1, 
GridBagConstraints.REMAINDER, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, 
GridBagConstraints.PAGE_START, new Insets(4,4,4,4));
-    addGBComponent(defaultsPanel,DefaultsPanel, 1, 0, 1, 
GridBagConstraints.REMAINDER, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, 
GridBagConstraints.PAGE_START, new Insets(4,4,4,4));
+    addGBComponent(configPanel,DefaultsPanel, 0, 0, 1, 
GridBagConstraints.REMAINDER, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, 
GridBagConstraints.PAGE_START, new Insets(4,5,4,5));
+    addGBComponent(defaultsPanel,DefaultsPanel, 1, 0, 1, 
GridBagConstraints.REMAINDER, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, 
GridBagConstraints.PAGE_START, new Insets(4,0,4,5));
     //defReloadButton.setEnabled(!applet);
     //defSaveButton.setEnabled(!applet);
 
@@ -210,13 +221,11 @@
     JPanel x509Panel = new JPanel(new GridBagLayout());
     x509Panel.setBorder(BorderFactory.createTitledBorder("X.509 
certificates"));
     ca = new JButton("Load CA certificate");
-    ca.setPreferredSize(new Dimension(145,25));
     ca.addActionListener(this);
     crl = new JButton("Load CRL certificate");
-    crl.setPreferredSize(new Dimension(145,25));
     crl.addActionListener(this);
-    addGBComponent(ca, x509Panel,  0, 0, 1, 1, 2, 2, 0, 1, 
GridBagConstraints.NONE, GridBagConstraints.LINE_START, new Insets(2,2,2,2));
-    addGBComponent(crl, x509Panel, 1, 0, 1, 1, 2, 2, 1, 1, 
GridBagConstraints.NONE, GridBagConstraints.LINE_START, new Insets(2,2,2,2));
+    addGBComponent(ca, x509Panel,  0, 0, 1, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new 
Insets(2,2,2,2));
+    addGBComponent(crl, x509Panel, 1, 0, 1, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new 
Insets(2,2,2,2));
 
     JPanel authPanel = new JPanel(new GridBagLayout());
     authPanel.setBorder(BorderFactory.createTitledBorder("Authentication"));
@@ -230,10 +239,10 @@
 
     secVeNCrypt = new JCheckBox("Extended encryption and authentication 
methods (VeNCrypt)");
     secVeNCrypt.addItemListener(this);
-    addGBComponent(secVeNCrypt,SecPanel,        0, 0, 1, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new 
Insets(0,2,0,20));
-    addGBComponent(encryptionPanel,SecPanel, 0, 1, 1, 1, 2, 2, 1, 0, 
GridBagConstraints.NONE, GridBagConstraints.LINE_START, new Insets(0,4,2,4));
-    addGBComponent(x509Panel,SecPanel,       0, 2, 1, 1, 2, 2, 1, 0, 
GridBagConstraints.NONE, GridBagConstraints.LINE_START, new Insets(2,4,2,4));
-    addGBComponent(authPanel,SecPanel,       0, 3, 1, 1, 2, 2, 1, 1, 
GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new 
Insets(2,4,2,4));
+    addGBComponent(secVeNCrypt,SecPanel,     0, 0, 1, 1, 2, 2, 1, 0, 
GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new 
Insets(4,5,0,30));
+    addGBComponent(encryptionPanel,SecPanel, 0, 1, 1, 1, 2, 2, 1, 0, 
GridBagConstraints.NONE, GridBagConstraints.LINE_START, new Insets(0,10,2,5));
+    addGBComponent(x509Panel,SecPanel,       0, 2, 1, 1, 2, 2, 1, 0, 
GridBagConstraints.NONE, GridBagConstraints.LINE_START, new Insets(2,10,2,5));
+    addGBComponent(authPanel,SecPanel,       0, 3, 1, 1, 2, 2, 1, 1, 
GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new 
Insets(2,10,2,5));
 
     tabPane.add(FormatPanel);
     tabPane.add(InputsPanel);
@@ -245,7 +254,7 @@
     tabPane.addTab("Misc", MiscPanel);
     tabPane.addTab("Load / Save", DefaultsPanel);
     tabPane.addTab("Security", SecPanel);
-    tabPane.setBorder(BorderFactory.createEmptyBorder(4,4,0,4));
+    tabPane.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
 
     okButton = new JButton("OK");
     okButton.setPreferredSize(new Dimension(90,30));
@@ -256,12 +265,12 @@
 
     JPanel buttonPane = new JPanel();
     buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
-    buttonPane.setBorder(BorderFactory.createEmptyBorder(4,0,0,0));
+    buttonPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     buttonPane.add(Box.createHorizontalGlue());
     buttonPane.add(okButton);
-    buttonPane.add(Box.createRigidArea(new Dimension(4,0)));
+    buttonPane.add(Box.createRigidArea(new Dimension(5,0)));
     buttonPane.add(cancelButton);
-    buttonPane.add(Box.createRigidArea(new Dimension(4,0)));
+    buttonPane.add(Box.createRigidArea(new Dimension(5,0)));
 
     this.getContentPane().add(tabPane);
     this.getContentPane().add(buttonPane);

Modified: trunk/java/com/tigervnc/vncviewer/ServerDialog.java
===================================================================
--- trunk/java/com/tigervnc/vncviewer/ServerDialog.java 2012-04-21 00:44:08 UTC 
(rev 4892)
+++ trunk/java/com/tigervnc/vncviewer/ServerDialog.java 2012-04-25 01:15:36 UTC 
(rev 4893)
@@ -67,7 +67,7 @@
     if (UIManager.getLookAndFeel().getID() == "Windows") {
       server.setBorder(BorderFactory.createCompoundBorder(server.getBorder(),
         BorderFactory.createEmptyBorder(0,2,0,0)));
-    } else {
+    } else if (UIManager.getLookAndFeel().getID() == "Metal") {
       ComboBoxEditor editor = server.getEditor();
       JTextField jtf = (JTextField)editor.getEditorComponent();
       jtf.setBorder(new CompoundBorder(jtf.getBorder(), new 
EmptyBorder(0,2,0,0)));

Modified: trunk/java/com/tigervnc/vncviewer/VncViewer.java
===================================================================
--- trunk/java/com/tigervnc/vncviewer/VncViewer.java    2012-04-21 00:44:08 UTC 
(rev 4892)
+++ trunk/java/com/tigervnc/vncviewer/VncViewer.java    2012-04-25 01:15:36 UTC 
(rev 4893)
@@ -43,6 +43,7 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import javax.swing.*;
+import javax.swing.plaf.FontUIResource;
 
 import com.tigervnc.rdr.*;
 import com.tigervnc.rfb.*;
@@ -63,23 +64,33 @@
 
   public static void setLookAndFeel() {
     try {
-      String os = System.getProperty("os.name");
-      if (os.startsWith("Windows")) {
-        String laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
-        UIManager.setLookAndFeel(laf);
-      } else {
+      String nativeLaf = UIManager.getSystemLookAndFeelClassName();
+      if (nativeLaf.endsWith("WindowsLookAndFeel"))
+        UIManager.setLookAndFeel(nativeLaf);
+      UIManager.put("TitledBorder.titleColor",Color.blue);
+      LookAndFeel laf = UIManager.getLookAndFeel();
+      if (laf == null)
+        return;
+      if (laf.getName().equals("Metal")) {
         UIManager.put("swing.boldMetal", Boolean.FALSE);
-        javax.swing.plaf.FontUIResource f = new
-          javax.swing.plaf.FontUIResource("SansSerif", Font.PLAIN, 11);
+        FontUIResource f = new FontUIResource("SansSerif", Font.PLAIN, 11);
         java.util.Enumeration keys = UIManager.getDefaults().keys();
         while (keys.hasMoreElements()) {
           Object key = keys.nextElement();
-          Object value = UIManager.get (key);
+          Object value = UIManager.get(key);
           if (value instanceof javax.swing.plaf.FontUIResource)
             UIManager.put(key, f);
         }
+      } else if (laf.getName().equals("Nimbus")) {
+        FontUIResource f;
+        String os = System.getProperty("os.name");
+        if (os.startsWith("Windows")) {
+          f = new FontUIResource("Verdana", 0, 11);
+        } else {
+          f = new FontUIResource("DejaVu Sans", 0, 11);
+        }
+       UIManager.put("TitledBorder.font", f);
       }
-      UIManager.put("TitledBorder.titleColor",Color.blue);
     } catch (java.lang.Exception e) { 
       vlog.info(e.toString());
     }

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

Reply via email to