summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorRobert Schuster <theBohemian@gmx.net>2006-05-23 10:45:33 +0000
committerRobert Schuster <theBohemian@gmx.net>2006-05-23 10:45:33 +0000
commit5096178717f8e36db025071dc1d4bad74d6a0ca0 (patch)
tree0ce93b40448c4a3a4fc02167f70ffe8b8c130678 /examples
parentd0e29509b6a6239192392108513d6c51a5ed5141 (diff)
downloadclasspath-5096178717f8e36db025071dc1d4bad74d6a0ca0.tar.gz
2006-05-23 Robert Schuster <robertschuster@fsfe.org>
* examples/gnu/classpath/examples/awt/Demo.java: (MainWindow.MainWindow): Added ResolutionWindow instance as subframe. (ResolutionWindow): New inner class.
Diffstat (limited to 'examples')
-rw-r--r--examples/gnu/classpath/examples/awt/Demo.java95
1 files changed, 95 insertions, 0 deletions
diff --git a/examples/gnu/classpath/examples/awt/Demo.java b/examples/gnu/classpath/examples/awt/Demo.java
index 64594e47b..5e668dde6 100644
--- a/examples/gnu/classpath/examples/awt/Demo.java
+++ b/examples/gnu/classpath/examples/awt/Demo.java
@@ -154,6 +154,8 @@ class Demo
addSubWindow ("RandomTests", new TestWindow (this));
addSubWindow ("RoundRect", new RoundRectWindow ());
addSubWindow ("Animation", new AnimationWindow ());
+ addSubWindow ("Resolution", new ResolutionWindow ());
+ addSubWindow ("Fullscreen", new FullscreenWindow ());
Panel sp = new Panel();
PrettyPanel p = new PrettyPanel();
@@ -744,6 +746,99 @@ class Demo
t.beep();
}
}
+
+ static class ResolutionWindow extends SubFrame
+ {
+ GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
+
+ public void init ()
+ {
+ initted = true;
+
+ setTitle("Change Screen Resolution");
+ final List list = new List();
+ DisplayMode[] modes = gd.getDisplayModes();
+
+ for (int i=0;i<modes.length;i++ )
+ list.add(modes[i].getWidth() + "x"
+ + modes[i].getHeight()
+ + ((modes[i].getBitDepth() != DisplayMode.BIT_DEPTH_MULTI)
+ ? "x" + modes[i].getBitDepth() + "bpp"
+ : "")
+ + ((modes[i].getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN)
+ ? "@" + modes[i].getRefreshRate() + "Hz"
+ : ""));
+
+ ActionListener al = new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ae)
+ {
+ int i = list.getSelectedIndex();
+ gd.setDisplayMode(gd.getDisplayModes()[i]);
+ }
+ };
+
+ Button b = new Button("Switch");
+ Button c = new Button("Close");
+
+ list.addActionListener(al);
+ b.addActionListener(al);
+
+ c.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ dispose();
+ }
+ });
+
+ setLayout(new GridLayout(3, 1, 5, 5));
+ add(list);
+ add(b);
+ add(c);
+
+ pack();
+ }
+ }
+
+ static class FullscreenWindow extends SubFrame
+ {
+ GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
+
+ public void init ()
+ {
+ initted = true;
+
+ setTitle("Fullscreen Exclusive Mode");
+
+ ActionListener al = new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ae)
+ {
+ if (gd.getFullScreenWindow() == FullscreenWindow.this)
+ gd.setFullScreenWindow(null);
+ else
+ gd.setFullScreenWindow(FullscreenWindow.this);
+ }
+ };
+
+ Button b = new Button("Toggle Fullscreen");
+ Button c = new Button("Close");
+
+ b.addActionListener(al);
+
+ c.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ gd.setFullScreenWindow(null);
+ dispose();
+ }
+ });
+
+ setLayout(new GridLayout(3, 1, 5, 5));
+ add(b);
+ add(c);
+
+ pack();
+ }
+ }
static class RoundRectWindow extends SubFrame
{