Feature - Implemented It would be nice if swingLookAndFeel could retain its value even if it is the default

parastra

New member
As of build 9955, the swingLookAndFeel setting controls the look and feel of the program, but as described in the linked post, if the value of the swingLookAndFeel setting is the same as the system default look and feel, swingLookAndFeel is set to "".

The problem with this is that if you regularly switch between different operating systems (with a different default look and feel), and the look and feel you have selected is the default on one OS, when you use that OS, swingLookAndFeel gets set to "", and when you switch to the other OS, instead of your selected look and feel, you get the default for that OS.

An example might be easier to follow...

I use mafia on both Linux and Windows, and I prefer to use javax.swing.plaf.metal.MetalLookAndFeel (which is apparently the system default on my Linux machine).

So, on Windows, I choose MetalLookAndFeel and my GLOBAL_Prefs.txt file now contains the following entry:
swingLookAndFeel=javax.swing.plaf.metal.MetalLookAndFeel

I switch to a Linux computer, mafia sees that swingLookAndFeel is javax.swing.plaf.metal.MetalLookAndFeel (the system default) and replaces it with "".
So now, GLOBAL_prefs.txt contains this:
swingLookAndFeel

I switch back to Windows, and since swingLookAndFeel is "", mafia uses com.sun.java.swing.plaf.windows.WindowsLookAndFeel, instead of the one I wanted.

If I specifically choose a look and feel in the preferences window, it would be nice if mafia could keep my selection in GLOBAL_prefs.txt, even if what I have chosen is the system default.

i.e. Something like this:

Code:
Index: src/net/sourceforge/kolmafia/KoLmafia.java
===================================================================
--- src/net/sourceforge/kolmafia/KoLmafia.java	(revision 10116)
+++ src/net/sourceforge/kolmafia/KoLmafia.java	(working copy)
@@ -436,14 +436,7 @@
 			SystemTrayFrame.addTrayIcon();
 		}
 
-		if ( lookAndFeel.equals( defaultLookAndFeel ) )
-		{
-			Preferences.setString( "swingLookAndFeel", "" );
-		}
-		else
-		{
-			Preferences.setString( "swingLookAndFeel", lookAndFeel );
-		}
+		Preferences.setString( "swingLookAndFeel", lookAndFeel );
 
 		if ( System.getProperty( "os.name" ).startsWith( "Win" ) || lookAndFeel.equals( UIManager.getCrossPlatformLookAndFeelClassName() ) )
 

holatuwol

Developer
Well, I specifically did it for myself so I could use different UI managers on Linux vs. OSX. So I've committed code to let me have things my way without interfering with people who wanted things the old way.
 
Top