001: package demo.notification.whiteboard;
002:
003: import java.util.Enumeration;
004: import java.awt.Frame;
005:
006: /**
007: * @author
008: * @version
009: */
010:
011: public class SelectDialog extends java.awt.Dialog {
012:
013: /** Initializes the Form */
014: public SelectDialog(Frame parentFrame,
015: WorkgroupController controller) {
016: super (parentFrame, "Select a Whiteboard");
017: initComponents();
018: controller_ = controller;
019: pack();
020: refresh();
021: }
022:
023: private void initComponents() {
024: addWindowListener(new java.awt.event.WindowAdapter() {
025: public void windowClosing(java.awt.event.WindowEvent evt) {
026: closeDialog(evt);
027: }
028: });
029: setLayout(new java.awt.BorderLayout());
030:
031: panel1 = new java.awt.Panel();
032: panel1.setName("buttonPanel");
033: panel1.setLayout(new java.awt.FlowLayout());
034:
035: joinButton = new java.awt.Button();
036: joinButton.setLabel("Join");
037: joinButton.setName("joinButton");
038: joinButton
039: .addActionListener(new java.awt.event.ActionListener() {
040: public void actionPerformed(
041: java.awt.event.ActionEvent evt) {
042: joinButtonActionPerformed(evt);
043: }
044: });
045: panel1.add(joinButton);
046:
047: refreshButton = new java.awt.Button();
048: refreshButton.setLabel("Refresh");
049: refreshButton.setName("refreshButton");
050: refreshButton
051: .addActionListener(new java.awt.event.ActionListener() {
052: public void actionPerformed(
053: java.awt.event.ActionEvent evt) {
054: refreshButtonActionPerformed(evt);
055: }
056: });
057: panel1.add(refreshButton);
058:
059: add(panel1, "South");
060:
061: availableList = new java.awt.List();
062: availableList
063: .addActionListener(new java.awt.event.ActionListener() {
064: public void actionPerformed(
065: java.awt.event.ActionEvent e) {
066: selectionTField.setText(availableList
067: .getSelectedItem());
068: }
069: });
070: availableList.setName("availableList");
071: add(availableList, "Center");
072:
073: selectionTField = new java.awt.TextField();
074: add(selectionTField, "North");
075:
076: }
077:
078: private void refreshButtonActionPerformed(
079: java.awt.event.ActionEvent evt) {
080: refresh();
081: }
082:
083: private void joinButtonActionPerformed(
084: java.awt.event.ActionEvent evt) {
085: String result = selectionTField.getText();
086: if (result.length() > 0) {
087: controller_.selectWhiteboard(result);
088: close();
089: }
090: }
091:
092: void refresh() {
093: availableList.removeAll();
094: String[] _list = controller_.getListOfWhiteboards();
095: for (int x = 0; x < _list.length; ++x) {
096: availableList.add(_list[x]);
097: }
098: }
099:
100: /** Closes the dialog */
101: private void closeDialog(java.awt.event.WindowEvent evt) {
102: close();
103: }
104:
105: void close() {
106: setVisible(false);
107: dispose();
108: }
109:
110: private java.awt.Panel panel1;
111: private java.awt.Button joinButton;
112: private java.awt.Button refreshButton;
113: private java.awt.List availableList;
114: private java.awt.TextField selectionTField;
115: private WorkgroupController controller_;
116: }
|