Now that the Metal Look and Feel starts to do something good, I think we
could show that in the Swing demo. The attached patch (and my previous
patch for UIManager) makes the Demo program aware of the system property
swing.defaultlaf. If this is not set, it prints out a short summary
which values can be set for this property.
If there are no objections to this, I will commit this soon.
2005-04-17 Roman Kennke <[EMAIL PROTECTED]>
* examples/gnu/classpath/exammples/swing/Demo.java:
Print a short summary for available values for the property
swing.defaultlaf.
Set MetalLookAndFeel as default.
Pulled out GNULookAndFeel so that it is accessible.
* examples/gnu/classpath/exammples/swing/GNULookAndFeel.java:
Pulled out this class from Demo.java.
/Roman
Index: examples/gnu/classpath/examples/swing/Demo.java
===================================================================
RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/swing/Demo.java,v
retrieving revision 1.6
diff -u -r1.6 Demo.java
--- examples/gnu/classpath/examples/swing/Demo.java 28 Feb 2005 16:51:04 -0000 1.6
+++ examples/gnu/classpath/examples/swing/Demo.java 17 Apr 2005 19:40:21 -0000
@@ -32,6 +32,7 @@
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
+import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.border.*;
import java.net.URL;
@@ -42,48 +43,28 @@
JFrame frame;
static Color blueGray = new Color(0xdc, 0xda, 0xd5);
- static class GNULookAndFeel extends BasicLookAndFeel
- {
- public boolean isNativeLookAndFeel() { return true; }
- public boolean isSupportedLookAndFeel() { return true; }
- public String getDescription() { return "GNU Look and Feel"; }
- public String getID() { return "GNULookAndFeel"; }
- public String getName() { return "GNU"; }
-
- static UIDefaults LAF_defaults;
-
- public UIDefaults getDefaults()
- {
- if (LAF_defaults == null)
- {
- LAF_defaults = super.getDefaults();
- Object[] myDefaults = new Object[] {
- "Button.background", new ColorUIResource(blueGray),
- "CheckBox.background", new ColorUIResource(blueGray),
- "CheckBoxMenuItem.background", new ColorUIResource(blueGray),
- "ToolBar.background", new ColorUIResource(blueGray),
- "Panel.background", new ColorUIResource(blueGray),
- "Slider.background", new ColorUIResource(blueGray),
- "OptionPane.background", new ColorUIResource(blueGray),
- "ProgressBar.background", new ColorUIResource(blueGray),
- "TabbedPane.background", new ColorUIResource(blueGray),
- "Label.background", new ColorUIResource(blueGray),
- "Menu.background", new ColorUIResource(blueGray),
- "MenuBar.background", new ColorUIResource(blueGray),
- "MenuItem.background", new ColorUIResource(blueGray),
- "ScrollBar.background", new ColorUIResource(blueGray)
- };
- LAF_defaults.putDefaults(myDefaults);
- }
- return LAF_defaults;
- }
- }
-
static
{
try
{
- UIManager.setLookAndFeel(new GNULookAndFeel());
+ if (System.getProperty("swing.defaultlaf") == null)
+ {
+ System.out.println();
+ System.out.println("You may change the Look and Feel of this");
+ System.out.println("Demo by setting the system property");
+ System.out.println("-Dswing.defaultlaf=<LAFClassName>");
+ System.out.println();
+ System.out.println("Possible values for <LAFClassName> are:");
+ System.out.println(" * javax.swing.plaf.metal.MetalLookAndFeel");
+ System.out.println("\tthe default Java L&F");
+ System.out.println(" * gnu.classpath.examples.swing.GNULookAndFeel");
+ System.out.print("\tthe GNU Look and Feel");
+ System.out.println("(derived from javax.swing.plaf.basic.BasicLookAndFeel");
+ System.out.println();
+ System.out.println("the default is javax.swing.plaf.metal.MetalLookAndFeel");
+
+ UIManager.setLookAndFeel(new MetalLookAndFeel());
+ }
}
catch (UnsupportedLookAndFeelException e)
{
Index: examples/gnu/classpath/examples/swing/GNULookAndFeel.java
===================================================================
RCS file: examples/gnu/classpath/examples/swing/GNULookAndFeel.java
diff -N examples/gnu/classpath/examples/swing/GNULookAndFeel.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ examples/gnu/classpath/examples/swing/GNULookAndFeel.java 17 Apr 2005 19:40:21 -0000
@@ -0,0 +1,68 @@
+/* GNULookAndFeel.java -- An example of using the javax.swing UI.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+*/
+
+package gnu.classpath.examples.swing;
+
+import java.awt.Color;
+
+import javax.swing.UIDefaults;
+import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.basic.BasicLookAndFeel;
+
+public class GNULookAndFeel extends BasicLookAndFeel
+{
+
+ static Color blueGray = new Color(0xdc, 0xda, 0xd5);
+
+ public boolean isNativeLookAndFeel() { return true; }
+ public boolean isSupportedLookAndFeel() { return true; }
+ public String getDescription() { return "GNU Look and Feel"; }
+ public String getID() { return "GNULookAndFeel"; }
+ public String getName() { return "GNU"; }
+
+ static UIDefaults LAF_defaults;
+
+ public UIDefaults getDefaults()
+ {
+ if (LAF_defaults == null)
+ {
+ LAF_defaults = super.getDefaults();
+ Object[] myDefaults = new Object[] {
+ "Button.background", new ColorUIResource(blueGray),
+ "CheckBox.background", new ColorUIResource(blueGray),
+ "CheckBoxMenuItem.background", new ColorUIResource(blueGray),
+ "ToolBar.background", new ColorUIResource(blueGray),
+ "Panel.background", new ColorUIResource(blueGray),
+ "Slider.background", new ColorUIResource(blueGray),
+ "OptionPane.background", new ColorUIResource(blueGray),
+ "ProgressBar.background", new ColorUIResource(blueGray),
+ "TabbedPane.background", new ColorUIResource(blueGray),
+ "Label.background", new ColorUIResource(blueGray),
+ "Menu.background", new ColorUIResource(blueGray),
+ "MenuBar.background", new ColorUIResource(blueGray),
+ "MenuItem.background", new ColorUIResource(blueGray),
+ "ScrollBar.background", new ColorUIResource(blueGray)
+ };
+ LAF_defaults.putDefaults(myDefaults);
+ }
+ return LAF_defaults;
+ }
+}
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches