summaryrefslogtreecommitdiff
path: root/java/gjt/YesNoDialog.java
diff options
context:
space:
mode:
authorpjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-04-07 18:12:58 +0000
committerpjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-04-07 18:12:58 +0000
commit28fdfa0225c92310a6f0d60f0cf8c334380e0828 (patch)
treeba4b0a7a26bf46ea298496a434496695db55bdc1 /java/gjt/YesNoDialog.java
parent9c4a1450aec6c149f6491194a48f34a57ed4c39b (diff)
downloadATCD-28fdfa0225c92310a6f0d60f0cf8c334380e0828.tar.gz
Added gjt to CVS
Diffstat (limited to 'java/gjt/YesNoDialog.java')
-rw-r--r--java/gjt/YesNoDialog.java80
1 files changed, 80 insertions, 0 deletions
diff --git a/java/gjt/YesNoDialog.java b/java/gjt/YesNoDialog.java
new file mode 100644
index 00000000000..2db64ea6e4b
--- /dev/null
+++ b/java/gjt/YesNoDialog.java
@@ -0,0 +1,80 @@
+package gjt;
+
+import java.awt.*;
+
+/**
+ * Similar in fuction to the MessageDialog, YesNoDialog poses
+ * a question, that is answered by selection of either a Yes
+ * button or a No button.<p>
+ *
+ * Note that the YesNoDialog is a singleton - meaning there is
+ * only one YesNoDialog in existence per applet. Clients
+ * may obtain the YesNoDialog by invoking getYesNoDialog().<p>
+ *
+ * @version 1.0, Apr 1 1996
+ * @author David Geary
+ * @see GJTDialog
+ * @see MessageDialog
+ * @see gjt.test.DialogTest
+ */
+public class YesNoDialog extends GJTDialog {
+ static private YesNoDialog _theYesNoDialog;
+ private Button yesButton;
+ private Button noButton;
+ private String message;
+ private boolean answer = false;
+ private ButtonPanel buttonPanel = new ButtonPanel();
+
+ static public YesNoDialog getYesNoDialog( Frame frame,
+ DialogClient client,
+ String title,
+ String message) {
+ if(_theYesNoDialog == null)
+ _theYesNoDialog = new YesNoDialog(frame,client,
+ title,message);
+ else {
+ _theYesNoDialog.setClient (client);
+ _theYesNoDialog.setTitle (title);
+ _theYesNoDialog.setMessage(message);
+ }
+ return _theYesNoDialog;
+ }
+ private YesNoDialog(Frame frame, DialogClient client,
+ String title, String message) {
+ super(frame, title, client, true);
+ yesButton = buttonPanel.add("Yes");
+ noButton = buttonPanel.add("No");
+
+ setLayout(new BorderLayout());
+ add("Center", new YesNoPanel(message));
+ add("South", buttonPanel);
+ pack();
+ }
+ public void show() {
+ yesButton.requestFocus();
+ super.show();
+ }
+ public boolean answeredYes() {
+ return answer;
+ }
+ public boolean action(Event event, Object what) {
+ if(event.target == yesButton) answer = true;
+ else answer = false;
+
+ hide();
+ client.dialogDismissed(this);
+ return true;
+ }
+ private void setMessage(String message) {
+ this.message = message;
+ }
+}
+
+class YesNoPanel extends Panel {
+ public YesNoPanel(String question) {
+ add("Center", new Label(question, Label.CENTER));
+ }
+ public Insets insets() {
+ return new Insets(10,10,10,10);
+ }
+}