1 package demo.notification.whiteboard; 2 3 import java.util.Enumeration ; 4 import java.awt.Frame ; 5 6 10 11 public class SelectDialog extends java.awt.Dialog { 12 13 14 public SelectDialog(Frame parentFrame, WorkgroupController controller) { 15 super (parentFrame, "Select a Whiteboard"); 16 initComponents (); 17 controller_ = controller; 18 pack (); 19 refresh(); 20 } 21 22 private void initComponents () { 23 addWindowListener (new java.awt.event.WindowAdapter () { 24 public void windowClosing (java.awt.event.WindowEvent evt) { 25 closeDialog (evt); 26 } 27 } 28 ); 29 setLayout (new java.awt.BorderLayout ()); 30 31 panel1 = new java.awt.Panel (); 32 panel1.setName ("buttonPanel"); 33 panel1.setLayout (new java.awt.FlowLayout ()); 34 35 joinButton = new java.awt.Button (); 36 joinButton.setLabel ("Join"); 37 joinButton.setName ("joinButton"); 38 joinButton.addActionListener (new java.awt.event.ActionListener () { 39 public void actionPerformed (java.awt.event.ActionEvent evt) { 40 joinButtonActionPerformed (evt); 41 } 42 } 43 ); 44 panel1.add (joinButton); 45 46 refreshButton = new java.awt.Button (); 47 refreshButton.setLabel ("Refresh"); 48 refreshButton.setName ("refreshButton"); 49 refreshButton.addActionListener (new java.awt.event.ActionListener () { 50 public void actionPerformed (java.awt.event.ActionEvent evt) { 51 refreshButtonActionPerformed (evt); 52 } 53 } 54 ); 55 panel1.add (refreshButton); 56 57 add (panel1, "South"); 58 59 availableList = new java.awt.List (); 60 availableList.addActionListener( new java.awt.event.ActionListener () { 61 public void actionPerformed(java.awt.event.ActionEvent e) { 62 selectionTField.setText(availableList.getSelectedItem() ); 63 } 64 } 65 ); 66 availableList.setName ("availableList"); 67 add (availableList, "Center"); 68 69 selectionTField = new java.awt.TextField (); 70 add (selectionTField, "North"); 71 72 } 73 74 private void refreshButtonActionPerformed (java.awt.event.ActionEvent evt) { 75 refresh(); 76 } 77 78 private void joinButtonActionPerformed (java.awt.event.ActionEvent evt) { 79 String result = selectionTField.getText(); 80 if ( result.length() > 0 ) { 81 controller_.selectWhiteboard(result); 82 close(); 83 } 84 } 85 86 void refresh() { 87 availableList.removeAll(); 88 String [] _list = controller_.getListOfWhiteboards(); 89 for (int x=0; x<_list.length; ++x) { 90 availableList.add(_list[x]); 91 } 92 } 93 94 95 private void closeDialog(java.awt.event.WindowEvent evt) { 96 close(); 97 } 98 99 void close() { 100 setVisible (false); 101 dispose (); 102 } 103 104 private java.awt.Panel panel1; 105 private java.awt.Button joinButton; 106 private java.awt.Button refreshButton; 107 private java.awt.List availableList; 108 private java.awt.TextField selectionTField; 109 private WorkgroupController controller_; 110 } 111 | Popular Tags |