summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2005-11-01 23:36:35 +0000
committerMark Wielaard <mark@klomp.org>2005-11-01 23:36:35 +0000
commitaa06cb1782758edd5ee206b05e2ebb7a5dcdb67a (patch)
treee63f7724d9a922087e101ae88c140dea07742d5f
parent58f4c37c11399077a5a27dd1b543ce145c356745 (diff)
downloadclasspath-aa06cb1782758edd5ee206b05e2ebb7a5dcdb67a.tar.gz
* examples/gnu/classpath/examples/swing/Demo.java (init): Use
JOptionPane to select the laf if not explicitly set.
-rw-r--r--ChangeLog5
-rw-r--r--examples/gnu/classpath/examples/swing/Demo.java34
2 files changed, 28 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index f0d632525..694ee5d58 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-11-01 Mark Wielaard <mark@klomp.org>
+
+ * examples/gnu/classpath/examples/swing/Demo.java (init): Use
+ JOptionPane to select the laf if not explicitly set.
+
2005-11-01 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/io/ObjectInputStream.java:
diff --git a/examples/gnu/classpath/examples/swing/Demo.java b/examples/gnu/classpath/examples/swing/Demo.java
index 6eec946a6..6e71af3c8 100644
--- a/examples/gnu/classpath/examples/swing/Demo.java
+++ b/examples/gnu/classpath/examples/swing/Demo.java
@@ -29,6 +29,9 @@ import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.border.*;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+import javax.swing.plaf.metal.OceanTheme;
+
import java.net.URL;
public class Demo
@@ -42,8 +45,6 @@ public class Demo
{
if (System.getProperty("swing.defaultlaf") == null)
{
- UIManager.setLookAndFeel(new GNULookAndFeel());
-
StringBuffer text = new StringBuffer();
text.append("You may change the Look and Feel of this\n");
text.append("Demo by setting the system property\n");
@@ -58,15 +59,26 @@ public class Demo
text.append(" the GNU Look and Feel\n");
text.append(" (derived from javax.swing.plaf.basic.BasicLookAndFeel)\n");
text.append("\n");
- text.append("the 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);
+ text.append("MetalLookAndFeel supports different Themes.\n");
+ text.append("DefaultMetalTheme (the default) and OceanTheme (in development)\n");
+
+ final String DEFAULT = "MetalLookAndFeel (default)";
+ final String OCEAN = "MetalLookAndFeel (Ocean)";
+ final String GNU = "GNULookAndFeel";
+ final String[] lafs = new String[] { DEFAULT, OCEAN, GNU };
+
+ int laf = JOptionPane.showOptionDialog(null, text /* textPane */,
+ "Look and Feel choice",
+ JOptionPane.OK_OPTION,
+ JOptionPane.QUESTION_MESSAGE,
+ null, lafs, DEFAULT);
+ if (laf == 1)
+ {
+ MetalLookAndFeel.setCurrentTheme(new OceanTheme());
+ UIManager.setLookAndFeel(new MetalLookAndFeel());
+ }
+ else if (laf == 2)
+ UIManager.setLookAndFeel(new GNULookAndFeel());
}
}
catch (UnsupportedLookAndFeelException e)