summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDavid Gilbert <david.gilbert@object-refinery.com>2006-01-30 23:18:18 +0000
committerDavid Gilbert <david.gilbert@object-refinery.com>2006-01-30 23:18:18 +0000
commit7a6f305b93ad23b6371ddb06cc1e9d19c2e7932d (patch)
tree61ee39468c15247255e1e7874fd41f947c3114df /examples
parentb4a94ad4a1a26d597b794d1e84c931ab24270836 (diff)
downloadclasspath-7a6f305b93ad23b6371ddb06cc1e9d19c2e7932d.tar.gz
2006-01-30 David Gilbert <david.gilbert@object-refinery.com>
* examples/gnu/classpath/examples/swing/ButtonDemo.java (ButtonDemo): Move content initialisation to new method, (initFrameContent): New method, (main): Call initFrameContent(), * examples/gnu/classpath/examples/swing/ComboBoxDemo.java: Likewise, * examples/gnu/classpath/examples/swing/FileChooserDemo.java: Likewise, * examples/gnu/classpath/examples/swing/ScrollBarDemo.java: Likewise, * examples/gnu/classpath/examples/swing/SliderDemo.java: Likewise, * examples/gnu/classpath/examples/swing/TextFieldDemo.java: Likewise.
Diffstat (limited to 'examples')
-rw-r--r--examples/gnu/classpath/examples/swing/ButtonDemo.java16
-rw-r--r--examples/gnu/classpath/examples/swing/ComboBoxDemo.java16
-rw-r--r--examples/gnu/classpath/examples/swing/FileChooserDemo.java16
-rw-r--r--examples/gnu/classpath/examples/swing/ScrollBarDemo.java16
-rw-r--r--examples/gnu/classpath/examples/swing/SliderDemo.java20
-rw-r--r--examples/gnu/classpath/examples/swing/TextFieldDemo.java18
6 files changed, 93 insertions, 9 deletions
diff --git a/examples/gnu/classpath/examples/swing/ButtonDemo.java b/examples/gnu/classpath/examples/swing/ButtonDemo.java
index ffe9fb236..856917fa9 100644
--- a/examples/gnu/classpath/examples/swing/ButtonDemo.java
+++ b/examples/gnu/classpath/examples/swing/ButtonDemo.java
@@ -1,5 +1,5 @@
/* ButtonDemo.java -- An example showing various buttons in Swing.
- Copyright (C) 2005, Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath examples.
@@ -79,6 +79,19 @@ public class ButtonDemo
{
super(title);
JPanel content = createContent();
+ // initFrameContent() is only called (from main) when running this app
+ // standalone
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ public void initFrameContent()
+ {
JPanel closePanel = new JPanel();
JButton closeButton = new JButton("Close");
closeButton.setActionCommand("CLOSE");
@@ -282,6 +295,7 @@ public class ButtonDemo
public static void main(String[] args)
{
ButtonDemo app = new ButtonDemo("Button Demo");
+ app.initFrameContent();
app.pack();
app.setVisible(true);
}
diff --git a/examples/gnu/classpath/examples/swing/ComboBoxDemo.java b/examples/gnu/classpath/examples/swing/ComboBoxDemo.java
index 9c893c287..2af619ca8 100644
--- a/examples/gnu/classpath/examples/swing/ComboBoxDemo.java
+++ b/examples/gnu/classpath/examples/swing/ComboBoxDemo.java
@@ -1,5 +1,5 @@
/* ComboBoxDemo.java -- An example showing various combo boxes in Swing.
- Copyright (C) 2005, Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath examples.
@@ -103,6 +103,19 @@ public class ComboBoxDemo
{
super(title);
JPanel content = createContent();
+ // initFrameContent() is only called (from main) when running this app
+ // standalone
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ public void initFrameContent()
+ {
JPanel closePanel = new JPanel();
JButton closeButton = new JButton("Close");
closeButton.setActionCommand("CLOSE");
@@ -357,6 +370,7 @@ public class ComboBoxDemo
e.printStackTrace();
}
ComboBoxDemo app = new ComboBoxDemo("ComboBox Demo");
+ app.initFrameContent();
app.pack();
app.setVisible(true);
}
diff --git a/examples/gnu/classpath/examples/swing/FileChooserDemo.java b/examples/gnu/classpath/examples/swing/FileChooserDemo.java
index 9e880f5dc..de86d2337 100644
--- a/examples/gnu/classpath/examples/swing/FileChooserDemo.java
+++ b/examples/gnu/classpath/examples/swing/FileChooserDemo.java
@@ -1,5 +1,5 @@
/* FileChooserDemo.java -- An example showing file choosers in Swing.
- Copyright (C) 2005, Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath examples.
@@ -87,6 +87,19 @@ public class FileChooserDemo extends JFrame implements ActionListener
{
super(frameTitle);
JPanel content = createContent();
+ // initFrameContent() is only called (from main) when running this app
+ // standalone
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ public void initFrameContent()
+ {
JPanel closePanel = new JPanel();
JButton closeButton = new JButton("Close");
closeButton.setActionCommand("CLOSE");
@@ -227,6 +240,7 @@ public class FileChooserDemo extends JFrame implements ActionListener
public static void main(String[] args)
{
FileChooserDemo app = new FileChooserDemo("File Chooser Demo");
+ app.initFrameContent();
app.pack();
app.setVisible(true);
}
diff --git a/examples/gnu/classpath/examples/swing/ScrollBarDemo.java b/examples/gnu/classpath/examples/swing/ScrollBarDemo.java
index f02728cab..f90ffd4ce 100644
--- a/examples/gnu/classpath/examples/swing/ScrollBarDemo.java
+++ b/examples/gnu/classpath/examples/swing/ScrollBarDemo.java
@@ -1,5 +1,5 @@
/* ScrollBarDemo.java -- An example showing scroll bars in Swing.
- Copyright (C) 2005, Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath examples.
@@ -51,6 +51,19 @@ public class ScrollBarDemo
{
super(title);
JPanel content = createContent();
+ // initFrameContent() is only called (from main) when running this app
+ // standalone
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ public void initFrameContent()
+ {
JPanel closePanel = new JPanel();
JButton closeButton = new JButton("Close");
closeButton.setActionCommand("CLOSE");
@@ -139,6 +152,7 @@ public class ScrollBarDemo
public static void main(String[] args)
{
ScrollBarDemo app = new ScrollBarDemo("ScrollBar Demo");
+ app.initFrameContent();
app.pack();
app.setVisible(true);
}
diff --git a/examples/gnu/classpath/examples/swing/SliderDemo.java b/examples/gnu/classpath/examples/swing/SliderDemo.java
index 86509827f..2bc510788 100644
--- a/examples/gnu/classpath/examples/swing/SliderDemo.java
+++ b/examples/gnu/classpath/examples/swing/SliderDemo.java
@@ -1,5 +1,5 @@
/* SliderDemo.java -- An example showing JSlider in various configurations.
- Copyright (C) 2005, Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath examples.
@@ -61,13 +61,26 @@ public class SliderDemo extends JFrame implements ActionListener
public SliderDemo(String frameTitle)
{
super(frameTitle);
- JPanel cont = createContent();
+ content = createContent();
+ // initFrameContent() is only called (from main) when running this app
+ // standalone
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ public void initFrameContent()
+ {
JPanel closePanel = new JPanel();
JButton closeButton = new JButton("Close");
closeButton.setActionCommand("CLOSE");
closeButton.addActionListener(this);
closePanel.add(closeButton);
- cont.add(closePanel, BorderLayout.SOUTH);
+ content.add(closePanel, BorderLayout.SOUTH);
getContentPane().add(content);
}
@@ -247,6 +260,7 @@ public class SliderDemo extends JFrame implements ActionListener
public static void main(String[] args)
{
SliderDemo app = new SliderDemo("Slider Demo");
+ app.initFrameContent();
app.pack();
app.setVisible(true);
}
diff --git a/examples/gnu/classpath/examples/swing/TextFieldDemo.java b/examples/gnu/classpath/examples/swing/TextFieldDemo.java
index 11850d07d..6eda46905 100644
--- a/examples/gnu/classpath/examples/swing/TextFieldDemo.java
+++ b/examples/gnu/classpath/examples/swing/TextFieldDemo.java
@@ -1,5 +1,5 @@
/* TextFieldDemo.java -- An example showing various textfields in Swing.
- Copyright (C) 2005, Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath examples.
@@ -117,7 +117,7 @@ public class TextFieldDemo
JTextField textfield3;
JCheckBox enabled1;
JCheckBox editable1;
-JPanel textFieldPanel1;
+ JPanel textFieldPanel1;
/**
* The right aligned textfields and state buttons.
*/
@@ -164,6 +164,19 @@ JPanel textFieldPanel1;
{
super(title);
JPanel content = createContent();
+ // initFrameContent() is only called (from main) when running this app
+ // standalone
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ public void initFrameContent()
+ {
JPanel closePanel = new JPanel();
JButton closeButton = new JButton("Close");
closeButton.setActionCommand("CLOSE");
@@ -486,6 +499,7 @@ JPanel textFieldPanel1;
public static void main(String[] args)
{
TextFieldDemo app = new TextFieldDemo("TextField Demo");
+ app.initFrameContent();
app.pack();
app.setVisible(true);
}