summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDavid Gilbert <david.gilbert@object-refinery.com>2005-09-29 22:15:21 +0000
committerDavid Gilbert <david.gilbert@object-refinery.com>2005-09-29 22:15:21 +0000
commit0a022780ca74d7d6dd3f2af77766ab2694af0da7 (patch)
tree88b19d08d9491d65748562263d2d3f67653fb15b /examples
parent59970db7fbd4bdf94f6c4946a262f46143523ab7 (diff)
downloadclasspath-0a022780ca74d7d6dd3f2af77766ab2694af0da7.tar.gz
2005-09-29 David Gilbert <david.gilbert@object-refinery.com>
* examples/gnu/classpath/examples/swing/ButtonDemo.java (createContent): add a close button, (actionPerformed): perform close action, * examples/gnu/classpath/examples/swing/ComboBoxDemo.java (createContent): add a close button, (actionPerformed): perform close action. ----------------------------------------------------------------------
Diffstat (limited to 'examples')
-rw-r--r--examples/gnu/classpath/examples/swing/ButtonDemo.java14
-rw-r--r--examples/gnu/classpath/examples/swing/ComboBoxDemo.java15
2 files changed, 27 insertions, 2 deletions
diff --git a/examples/gnu/classpath/examples/swing/ButtonDemo.java b/examples/gnu/classpath/examples/swing/ButtonDemo.java
index ee59f8341..7ac3d13b4 100644
--- a/examples/gnu/classpath/examples/swing/ButtonDemo.java
+++ b/examples/gnu/classpath/examples/swing/ButtonDemo.java
@@ -81,12 +81,20 @@ public class ButtonDemo
private JPanel createContent()
{
+ JPanel content = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(4, 1));
panel.add(createButtonPanel());
panel.add(createTogglePanel());
panel.add(createCheckBoxPanel());
panel.add(createRadioPanel());
- return panel;
+ content.add(panel);
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ content.add(closePanel, BorderLayout.SOUTH);
+ return content;
}
private JPanel createButtonPanel()
@@ -252,6 +260,10 @@ public class ButtonDemo
radio2.setEnabled(radioState.isSelected());
radio3.setEnabled(radioState.isSelected());
}
+ else if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
}
public static void main(String[] args)
diff --git a/examples/gnu/classpath/examples/swing/ComboBoxDemo.java b/examples/gnu/classpath/examples/swing/ComboBoxDemo.java
index e2dec03a1..24ae555d6 100644
--- a/examples/gnu/classpath/examples/swing/ComboBoxDemo.java
+++ b/examples/gnu/classpath/examples/swing/ComboBoxDemo.java
@@ -31,6 +31,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
+import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
@@ -78,13 +79,21 @@ public class ComboBoxDemo
private JPanel createContent()
{
+ JPanel content = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(5, 1));
panel.add(createPanel1());
panel.add(createPanel2());
panel.add(createPanel3());
panel.add(createPanel4());
panel.add(createPanel5());
- return panel;
+ content.add(panel);
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ content.add(closePanel, BorderLayout.SOUTH);
+ return content;
}
private JPanel createPanel1()
@@ -252,6 +261,10 @@ public class ComboBoxDemo
combo9.setEnabled(comboState5.isSelected());
combo10.setEnabled(comboState5.isSelected());
}
+ else if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
}
public static void main(String[] args)