1 26 27 package org.objectweb.ccm.chat.monolithic; 28 29 import org.objectweb.ccm.chat.*; 30 31 42 43 public class ClientImpl 44 extends org.omg.CORBA.LocalObject 45 implements CCM_Client, 46 org.omg.Components.SessionComponent, 47 java.awt.event.ActionListener 48 { 49 55 56 private String name_; 57 58 59 private java.awt.Frame frame_; 60 61 private java.awt.TextField text_; 62 63 private java.awt.TextArea textArea_; 64 65 66 private CCM_Client_Context the_context_; 67 68 69 public static final java.awt.Color white_ = java.awt.Color.white; 70 71 72 78 79 public 80 ClientImpl() 81 { 82 } 83 84 90 96 102 108 public void 109 configuration_complete() 110 throws org.omg.Components.InvalidConfiguration 111 { 112 if(name_ == null) 114 throw new org.omg.Components.InvalidConfiguration(); 115 116 if(the_context_.get_connection_the_service() == null) 118 throw new org.omg.Components.InvalidConfiguration(); 119 120 frame_ = new java.awt.Frame (name_ + "'s Chat GUI"); 123 124 textArea_ = new java.awt.TextArea (); 126 textArea_.setEditable(false); 127 textArea_.setBackground(white_); 128 129 130 text_ = new java.awt.TextField ("", 1); 132 java.awt.Button button = new java.awt.Button ("Print Text"); 134 button.addActionListener(this); 135 java.awt.Panel panel = new java.awt.Panel ( 137 new java.awt.BorderLayout () 138 ); 139 System.out.println("___________________________"); 140 frame_.setLayout ( new java.awt.BorderLayout () ) ; 141 frame_.add(panel); 142 143 panel.add(textArea_,java.awt.BorderLayout.NORTH); 144 panel.add(text_,java.awt.BorderLayout.CENTER); 145 panel.add(button,java.awt.BorderLayout.SOUTH); 146 147 frame_.setSize(400,300); 148 frame_.pack(); 149 frame_.show(); 150 } 151 152 158 165 public void 166 set_session_context(org.omg.Components.SessionContext context) 167 throws org.omg.Components.CCMException 168 { 169 the_context_ = (CCM_Client_Context)context; 170 } 171 172 177 public void 178 ccm_activate() 179 throws org.omg.Components.CCMException 180 { 181 } 183 184 189 public void 190 ccm_passivate() 191 throws org.omg.Components.CCMException 192 { 193 } 195 196 201 public void 202 ccm_remove() 203 throws org.omg.Components.CCMException 204 { 205 if(frame_!=null) 207 frame_.dispose(); 208 frame_ = null; 209 } 210 211 217 222 public void 223 name(String n) 224 { 225 name_ = n; 226 227 if (frame_ != null) 228 frame_.setTitle(name_ + "'s Client GUI"); 229 } 230 231 236 public String 237 name() 238 { 239 return name_; 240 } 241 242 248 253 public void 254 actionPerformed(java.awt.event.ActionEvent e) 255 { 256 Service service = the_context_.get_connection_the_service(); 259 260 if(service == null) 262 { 263 System.err.println("The chat::Client::the_service receptacle is not set!"); 264 return; 265 } 266 267 service.display(name_ + ":" + text_.getText()); 269 270 text_.setText(""); 272 273 } 274 275 276 277 283 284 public void 285 push_from_servers(TextEvent event) 286 { 287 push(event); 288 } 289 290 291 292 298 303 public void 304 push(TextEvent event) 305 { 306 textArea_.append(event.text + "\n"); 308 } 309 310 311 } 312 | Popular Tags |