This implements the system property swing.metalTheme as documented:
http://java.sun.com/j2se/1.5.0/docs/guide/swing/1.5/index.html
which allows setting Swing to the pre-1.5 theme.
2006-08-14 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/plaf/metal/MetalLookAndFeel.java
(MetalLookAndFeel): Moved theme initialization to
getDefaults().
(createDefaultTheme): Forward to getCurrentTheme().
(getDefaults): Initialize theme before doing anything else.
(getCurrentTheme): Recognize swing.metalTheme property.
/Roman
Index: javax/swing/plaf/metal/MetalLookAndFeel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java,v
retrieving revision 1.85
diff -u -1 -2 -r1.85 MetalLookAndFeel.java
--- javax/swing/plaf/metal/MetalLookAndFeel.java 22 Jul 2006 15:45:20 -0000 1.85
+++ javax/swing/plaf/metal/MetalLookAndFeel.java 14 Aug 2006 15:13:27 -0000
@@ -29,24 +29,26 @@
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package javax.swing.plaf.metal;
+import gnu.classpath.SystemProperties;
+
import java.awt.Color;
import java.awt.Font;
import javax.swing.LookAndFeel;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.BorderUIResource.LineBorderUIResource;
import javax.swing.plaf.basic.BasicLookAndFeel;
@@ -72,34 +74,33 @@
/** The current theme. */
private static MetalTheme theme;
/** The look and feel defaults. */
private UIDefaults LAF_defaults;
/**
* Creates a new instance of the Metal look and feel.
*/
public MetalLookAndFeel()
{
- createDefaultTheme();
+ // Nothing to do here.
}
/**
- * Sets the current theme to a new instance of [EMAIL PROTECTED] OceanTheme}.
+ * Sets the current theme to a new instance of [EMAIL PROTECTED] DefaultMetalTheme}.
*/
protected void createDefaultTheme()
{
- if (theme == null)
- setCurrentTheme(new OceanTheme());
+ getCurrentTheme();
}
/**
* Returns <code>false</code> to indicate that this look and feel does not
* attempt to emulate the look and feel of native applications on the host
* platform.
*
* @return <code>false</code>.
*/
public boolean isNativeLookAndFeel()
{
return false;
@@ -140,24 +141,25 @@
/**
* Returns the look and feel name.
*
* @return "MetalLookAndFeel".
*/
public String getName()
{
return "Metal";
}
public UIDefaults getDefaults()
{
+ createDefaultTheme();
if (LAF_defaults == null)
{
LAF_defaults = super.getDefaults();
// add custom theme entries to the table
if (theme != null)
theme.addCustomEntriesToTable(LAF_defaults);
}
// Returns the default values for this look and feel.
return LAF_defaults;
}
@@ -1345,25 +1347,32 @@
/**
* Returns the current theme for the Metal look and feel. The default is
* an instance of [EMAIL PROTECTED] OceanTheme}.
*
* @return The current theme (never <code>null</code>).
*
* @see #setCurrentTheme(MetalTheme)
*/
public static MetalTheme getCurrentTheme()
{
if (theme == null)
- theme = new OceanTheme();
+ {
+ // swing.metalTheme property documented here:
+ // http://java.sun.com/j2se/1.5.0/docs/guide/swing/1.5/index.html
+ if ("steel".equals(SystemProperties.getProperty("swing.metalTheme")))
+ theme = new DefaultMetalTheme();
+ else
+ theme = new OceanTheme();
+ }
return theme;
}
/**
* Returns <code>true</code> because the Metal look
* and feel supports window decorations for toplevel
* containers.
*
* @return <code>true</code>
*/
public boolean getSupportsWindowDecorations()
{