Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / examples / Simulator / DOVEBrowser / ObservablesDialog.java
blob70f04a4f3185085998ebf2b67332217b97535c38
1 //
2 // = FILENAME
3 // ObservablesDialog.java
4 //
5 // = AUTHOR
6 // Michael Kircher (mk1@cs.wustl.edu)
7 //
8 // = DESCRIPTION
9 // Dialog for selecting Observables.
11 // ============================================================================
13 import java.awt.*;
14 import java.awt.event.*;
16 public class ObservablesDialog extends Dialog {
18 List list_;
19 DemoCore parent_;
20 AnswerListener listener_;
22 ObservablesDialog (DemoCore parent,java.util.Enumeration enumeration) {
24 super ((Frame)parent, "Select Observables", true);
25 parent_ = parent;
26 this.setSize(400, 300);
27 setBounds (new Rectangle (50,50,400,300));
29 list_ = new List ();
30 list_.setFont ( new Font ("Helvetica", Font.PLAIN, 10));
31 list_.setSize (200,200);
33 for (; enumeration.hasMoreElements();) {
34 list_.add ((String)enumeration.nextElement());
38 Button ok_button_ = new Button ("OK");
39 ok_button_.setFont ( new Font ("DialogHelvetica", Font.PLAIN, 10));
40 Button cancel_button_ = new Button ("Cancel");
41 cancel_button_.setFont ( new Font ("DialogHelvetica", Font.PLAIN, 10));
43 GridBagLayout gridbag_ = new GridBagLayout ();
44 GridBagConstraints constraints_ = new GridBagConstraints ();
46 constraints_.fill = GridBagConstraints.BOTH;
47 this.setLayout (gridbag_);
49 constraints_.weightx = 1.0;
50 constraints_.weighty = 1.0;
51 constraints_.gridwidth = GridBagConstraints.REMAINDER;
52 gridbag_.setConstraints (list_, constraints_);
53 this.add (list_);
55 constraints_.weightx = 1.0;
56 constraints_.weighty = 1.0;
57 constraints_.gridwidth = GridBagConstraints.RELATIVE;
58 constraints_.fill = GridBagConstraints.NONE;
59 gridbag_.setConstraints (ok_button_, constraints_);
60 gridbag_.setConstraints (cancel_button_, constraints_);
61 this.add (ok_button_);
62 this.add (cancel_button_);
64 ok_button_.addActionListener (new ActionListener () {
65 public void actionPerformed (ActionEvent e) {
67 String selected_ = ObservablesDialog.this.list_.getSelectedItem ();
68 if (selected_ != null) {
69 System.out.println (">>>>> " + selected_);
70 if (listener_ != null) {
71 AnswerEvent ev = new AnswerEvent (ObservablesDialog.this, selected_);
72 listener_.ok (ev);
74 ObservablesDialog.this.setVisible (false);
77 });
79 cancel_button_.addActionListener (new ActionListener () {
80 public void actionPerformed (ActionEvent e) {
81 ObservablesDialog.this.setVisible (false);
83 });
86 public void addAnswerListener (AnswerListener al) {
87 listener_ = al;