summaryrefslogtreecommitdiff
path: root/examples/gnu/classpath
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2005-04-19 06:54:22 +0000
committerRoman Kennke <roman@kennke.org>2005-04-19 06:54:22 +0000
commit6007c697cca98f7aa79c9bab679860dfd7e441cc (patch)
treed411be4b9012fe33f94bb1e05e824b499c91d97b /examples/gnu/classpath
parente3f30154d0d09942d0bb4f018c7bdf02debc5adf (diff)
downloadclasspath-6007c697cca98f7aa79c9bab679860dfd7e441cc.tar.gz
2005-04-19 Roman Kennke <roman@kennke.org>
* examples/gnu/classpath/examples/swing/Demo.java: Pulled out GNULookAndFeel so that it can be accessed. On startup, if the property swing.defaultlaf is not set, display a message on how to set the L&F for the demo. Changed font for bottom buttons to normal. * examples/gnu/classpath/examples/swing/GNULookAndFeel.java: Pulled out of Demo.java.
Diffstat (limited to 'examples/gnu/classpath')
-rw-r--r--examples/gnu/classpath/examples/swing/Demo.java65
-rw-r--r--examples/gnu/classpath/examples/swing/GNULookAndFeel.java68
2 files changed, 94 insertions, 39 deletions
diff --git a/examples/gnu/classpath/examples/swing/Demo.java b/examples/gnu/classpath/examples/swing/Demo.java
index 52b74a86a..e6d1ef761 100644
--- a/examples/gnu/classpath/examples/swing/Demo.java
+++ b/examples/gnu/classpath/examples/swing/Demo.java
@@ -32,6 +32,7 @@ import javax.swing.*;
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 @@ public class Demo
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 @@ public class Demo
{
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;
}
diff --git a/examples/gnu/classpath/examples/swing/GNULookAndFeel.java b/examples/gnu/classpath/examples/swing/GNULookAndFeel.java
new file mode 100644
index 000000000..9c8e4c310
--- /dev/null
+++ b/examples/gnu/classpath/examples/swing/GNULookAndFeel.java
@@ -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;
+ }
+}