Am Dienstag, den 19.04.2005, 00:05 +0200 schrieb Mark Wielaard:
> Hi Roman,
>
> On Sun, 2005-04-17 at 21:45 +0200, Roman Kennke wrote:
> > Now that the Metal Look and Feel starts to do something good, I think we
> > could show that in the Swing demo.
> Just nitpicking but I think it would be nicer to have the message in a
> little window (maybe one that pops up from a new help->about menuitem).
Right. I implemented this. It shows up on startup only if the property
swing.defaultlaf isn't set. (If that is not what you wish, let me know,
I can pull it into a menu if that is better).
Thinking about it, it may make sense to actually ask the user for what
L&F he prefers. At this point the L&F still can be changed, as opposed
to later, when the app is running.
> Also it looks like the BasicLookAndFeel currently is a little nicer for
> this Demo then the Metal one (see the internal frame selection issue in
> Desktop World and the HSB part of the Colorpicker for example). So I
> would default to the GNULookAndFeel.
I have fixed the issues with internal frames and the slider. But you are
right, the BasicLookAndFeel is slightly more consistent than Metal L&F
at this point. Metal is half-Metal half-Basic ATM. I have changed to
GNULookAndFeel as default.
/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 19 Apr 2005 06:50:31 -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,34 @@
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)
+ {
+ StringBuffer text = new StringBuffer();
+ text.append("\tYou may change the Look and Feel of this\n");
+ text.append("\tDemo by setting the system property\n");
+ text.append("\t-Dswing.defaultlaf=<LAFClassName>\n\n");
+ text.append("\tPossible values for <LAFClassName> are:\n");
+ text.append("\t * javax.swing.plaf.metal.MetalLookAndFeel\n");
+ text.append("\t\tthe default Java L&F\n");
+ text.append("\t * gnu.classpath.examples.swing.GNULookAndFeel\n");
+ text.append("\tthe GNU Look and Feel\n");
+ text.append("\t(derived from javax.swing.plaf.basic.BasicLookAndFeel\n\n");
+ text.append("\tthe default is gnu.classpath.examples.swing.GNULookAndFeel\n");
+ JEditorPane textPane = new JEditorPane();
+ // temporary hack, preferred size should be computed by the
+ // component
+ textPane.setPreferredSize(new Dimension(400, 300));
+ textPane.setText(text.toString());
+ JOptionPane.showMessageDialog(null, textPane,
+ "Look and Feel notice",
+ JOptionPane.INFORMATION_MESSAGE);
+
+ UIManager.setLookAndFeel(new GNULookAndFeel());
+ }
}
catch (UnsupportedLookAndFeelException e)
{
@@ -566,7 +553,7 @@
{
JButton b = new JButton(title);
b.setMargin(new Insets(5,5,5,5));
- b.setFont(new Font("Luxi", Font.PLAIN, 14));
+ //b.setFont(new Font("Luxi", Font.PLAIN, 14));
return b;
}
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 19 Apr 2005 06:50:31 -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