Hallo all,

I have noticed that you hardcoded names of the classes, which implement different LookAndFeels. Having done this you at least ignore GTK+ LookAndFeel available on Linux.

I have put together a patch, which allows you not to code any names of the LookAndFeel implementations, but rather obtain the names via

UIManager.getInstalledLookAndFeels()

Please find the patch attached. It can be applied to JXplorer 3.2b2

What do you think about it?

Best regards, vadim tarassov


Index: /home/vadim/workspace1/jxplorer/src/com/ca/directory/jxplorer/AdvancedOptions.java
===================================================================
--- /home/vadim/workspace1/jxplorer/src/com/ca/directory/jxplorer/AdvancedOptions.java	(.../home/vadim/workspace1/jxplorer/src)	(revision 17)
+++ /home/vadim/workspace1/jxplorer/src/com/ca/directory/jxplorer/AdvancedOptions.java	(.../https://vadim.homelinux.org/svn/jxplorer/src)	(working copy)
@@ -235,14 +235,12 @@
      */
     private void getLookAndFeel()
     {
-        lookAndFeelVal = new String[]{"com.sun.java.swing.plaf.windows.WindowsLookAndFeel",
-                                      "javax.swing.plaf.metal.MetalLookAndFeel",
-                                      "com.sun.java.swing.plaf.motif.MotifLookAndFeel",
-                                      "com.sun.java.swing.plaf.mac.MacLookAndFeel"};
+        
+        UIManager.LookAndFeelInfo[] installedLAFs = UIManager.getInstalledLookAndFeels();
 
-        for (int i = 0; i < 4; i++)
+        for (int i = 0; i < installedLAFs.length; i++)
         {
-            if (String.valueOf(lookAndFeelVal[i]).equalsIgnoreCase(JXplorer.getProperty("gui.lookandfeel")))
+            if (installedLAFs[i].getClassName().equals(JXplorer.getProperty("gui.lookandfeel")))
                 lookAndFeel[i].setSelected(true);
         }
     }
@@ -488,6 +486,7 @@
         JRadioButton rb = null;    //TE: used for exception info.
 
         String currentLF = JXplorer.getProperty("gui.lookandfeel");
+        boolean	haveToChangeLAF = false;
 
         try
         {
@@ -496,44 +495,17 @@
         	
         	for(int i = 0; i < installedLAFs.length; i ++){
         		if(lookAndFeel[i].isSelected() == true){
-        			rb = setNewLookAndFeel(installedLAFs[i].getClassName(), i);
+        			// Don't change it unless we have to...
+        			if(!currentLF.equals(installedLAFs[i].getClassName())){
+        				rb = setNewLookAndFeel(installedLAFs[i].getClassName(), i);
+        				haveToChangeLAF = true;
+        			}
         		}
         	}
         	
-        	/*
-            if ((lookAndFeel[WINDOWS].isSelected()) == true)
-            {
-                // Don't change it unless we have to...
-                if(currentLF.equalsIgnoreCase(WINDOWS_LF))
-                    return;
-
-                rb = setNewLookAndFeel(WINDOWS_LF, WINDOWS);
-            }
-            else if ((lookAndFeel[JAVA].isSelected()) == true)
-            {
-                // Don't change it unless we have to...
-                if(currentLF.equalsIgnoreCase(JAVA_LF))
-                    return;
-
-                rb = setNewLookAndFeel(JAVA_LF, JAVA);
-            }
-            else if ((lookAndFeel[MOTIF].isSelected()) == true)
-            {
-                // Don't change it unless we have to...
-                if(currentLF.equalsIgnoreCase(MOTIF_LF))
-                    return;
-
-                rb = setNewLookAndFeel(MOTIF_LF, MOTIF);
-            }
-            else if ((lookAndFeel[MAC].isSelected()) == true)
-            {
-                // Don't change it unless we have to...
-                if(currentLF.equalsIgnoreCase(MAC_LF))
-                    return;
-
-                rb = setNewLookAndFeel(MAC_LF, MAC);
-            }
-            */
+        	if(!haveToChangeLAF){
+        		return;
+        	}
         }
         catch (UnsupportedLookAndFeelException exc)  // It can throw an exception if you try to set windows on a non-windows box.
         {

Reply via email to