diff options
author | Roman Kennke <roman@kennke.org> | 2005-04-19 06:54:22 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2005-04-19 06:54:22 +0000 |
commit | 6007c697cca98f7aa79c9bab679860dfd7e441cc (patch) | |
tree | d411be4b9012fe33f94bb1e05e824b499c91d97b /examples/gnu/classpath/examples/swing/Demo.java | |
parent | e3f30154d0d09942d0bb4f018c7bdf02debc5adf (diff) | |
download | classpath-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/examples/swing/Demo.java')
-rw-r--r-- | examples/gnu/classpath/examples/swing/Demo.java | 65 |
1 files changed, 26 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; } |