Source code: emc/gui/QueryDialog.java
1 package emc.gui;
2
3 import java.awt.*;
4 import java.awt.event.*;
5
6 /*
7 *
8 * QueryDialog
9 *
10 */
11 public class QueryDialog extends Dialog implements ActionListener
12 {
13 GridBagLayout lmInner = null;
14 Panel innerPanel = null;
15 TextArea msgArea = null;
16 Button okButton = null;
17 Button cancelButton = null;
18 FlowLayout lm = null;
19 public boolean done = false;
20 public boolean ok = false;
21
22 Dimension d = new Dimension(320,240);
23
24 QueryDialog(Frame parent, String title, String message)
25 {
26 super(parent, title, true);
27 lm = new FlowLayout(FlowLayout.LEFT);
28 setLayout(lm);
29 innerPanel = new Panel();
30 lmInner = new GridBagLayout();
31 innerPanel.setLayout(lmInner);
32 GridBagConstraints c = new GridBagConstraints();
33 msgArea = new TextArea(message,5,40);
34 msgArea.setEditable(false);
35 innerPanel.add(msgArea);
36 c.gridx = 0;
37 c.gridy = 0;
38 c.gridwidth = 2;
39 lmInner.setConstraints(msgArea,c);
40 okButton = new Button("OK");
41 okButton.addActionListener(this);
42 innerPanel.add(okButton);
43 c.gridx = 0;
44 c.gridy = 1;
45 c.gridwidth = 1;
46 lmInner.setConstraints(okButton,c);
47 cancelButton = new Button("CANCEL");
48 cancelButton.addActionListener(this);
49 innerPanel.add(cancelButton);
50 c.gridx = 1;
51 c.gridy = 1;
52 c.gridwidth = 1;
53 lmInner.setConstraints(cancelButton,c);
54 add(innerPanel);
55 setSize(d);
56 System.out.println("Showing QueryDialog with message = "+message);
57 show();
58 }
59
60 public void actionPerformed(ActionEvent evt)
61 {
62 if(evt.getSource() == okButton)
63 {
64 ok = true;
65 done = true;
66 dispose();
67 }
68 if(evt.getSource() == cancelButton)
69 {
70 ok = false;
71 done = true;
72 dispose();
73 }
74 }
75
76 public Dimension getPreferredSize()
77 {
78 return d;
79 }
80
81 public Dimension getMinimumSize()
82 {
83 return d;
84 }
85
86
87
88 }
89
90
91
92