1 26 27 package org.objectweb.ccm.demo1.cif; 28 29 import org.objectweb.ccm.demo1.Display; 30 31 45 46 public class ClientImpl 47 extends org.objectweb.ccm.demo1.ClientSessionComposition.ComponentImpl 48 implements java.awt.event.ActionListener 49 { 50 56 57 private String name_; 58 59 60 private javax.swing.JFrame frame_; 61 62 63 private javax.swing.JTextField text_; 64 65 71 72 public 73 ClientImpl() 74 { 75 } 76 77 83 89 95 101 public void 102 configuration_complete() 103 throws org.omg.Components.InvalidConfiguration 104 { 105 if(name_ == null) 107 throw new org.omg.Components.InvalidConfiguration(); 108 109 if(get_context().get_connection_to_server() == null) 111 throw new org.omg.Components.InvalidConfiguration(); 112 113 115 frame_ = new javax.swing.JFrame (name_ + "'s Client GUI"); 117 frame_.setSize(400, 300); 119 120 text_ = new javax.swing.JTextField ("", 1); 122 123 javax.swing.JButton button = new javax.swing.JButton ("Print Text"); 125 button.addActionListener(this); 126 127 javax.swing.JPanel panel = new javax.swing.JPanel ( 129 new java.awt.BorderLayout ()); 130 frame_.getContentPane().add(panel); 131 panel.add(new javax.swing.JScrollPane (text_), 132 java.awt.BorderLayout.CENTER); 133 panel.add(button, java.awt.BorderLayout.SOUTH); 134 frame_.pack(); 135 frame_.show(); 136 } 137 138 144 149 public void 150 ccm_remove() 151 throws org.omg.Components.CCMException 152 { 153 frame_.dispose(); 155 frame_ = null; 156 } 157 158 164 169 public void 170 the_name(String n) 171 { 172 name_ = n; 173 174 if (frame_ != null) 175 frame_.setTitle(name_ + "'s Client GUI"); 176 } 177 178 183 public String 184 the_name() 185 { 186 return name_; 187 } 188 189 195 200 public void 201 actionPerformed(java.awt.event.ActionEvent e) 202 { 203 Display to_server = get_context().get_connection_to_server(); 206 207 if(to_server == null) 209 { 210 System.err.println("The demo1::Client::to_server receptacle is not set!"); 211 return; 212 } 213 214 to_server.print(name_ + ":" + text_.getText()); 216 } 217 } 218 | Popular Tags |