1 26 27 package org.objectweb.ccm.demo1.monolithic; 28 29 import org.objectweb.ccm.demo1.*; 30 31 43 44 public class ClientImpl 45 extends org.omg.CORBA.LocalObject 46 implements CCM_Client, 47 org.omg.Components.SessionComponent, 48 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 66 private CCM_Client_Context the_context_; 67 68 74 75 public 76 ClientImpl() 77 { 78 } 79 80 86 92 98 104 public void 105 configuration_complete() 106 throws org.omg.Components.InvalidConfiguration 107 { 108 if(name_ == null) 110 throw new org.omg.Components.InvalidConfiguration(); 111 112 if(the_context_.get_connection_to_server() == null) 114 throw new org.omg.Components.InvalidConfiguration(); 115 116 118 frame_ = new javax.swing.JFrame (name_ + "'s Client GUI"); 120 frame_.setSize(400, 300); 122 123 text_ = new javax.swing.JTextField ("", 1); 125 126 javax.swing.JButton button = new javax.swing.JButton ("Print Text"); 128 button.addActionListener(this); 129 130 javax.swing.JPanel panel = new javax.swing.JPanel ( 132 new java.awt.BorderLayout ()); 133 frame_.getContentPane().add(panel); 134 panel.add(new javax.swing.JScrollPane (text_), 135 java.awt.BorderLayout.CENTER); 136 panel.add(button, java.awt.BorderLayout.SOUTH); 137 frame_.pack(); 138 frame_.show(); 139 } 140 141 147 154 public void 155 set_session_context(org.omg.Components.SessionContext context) 156 throws org.omg.Components.CCMException 157 { 158 the_context_ = (CCM_Client_Context)context; 159 } 160 161 166 public void 167 ccm_activate() 168 throws org.omg.Components.CCMException 169 { 170 } 172 173 178 public void 179 ccm_passivate() 180 throws org.omg.Components.CCMException 181 { 182 } 184 185 190 public void 191 ccm_remove() 192 throws org.omg.Components.CCMException 193 { 194 frame_.dispose(); 196 frame_ = null; 197 } 198 199 205 210 public void 211 the_name(String n) 212 { 213 name_ = n; 214 215 if (frame_ != null) 216 frame_.setTitle(name_ + "'s Client GUI"); 217 } 218 219 224 public String 225 the_name() 226 { 227 return name_; 228 } 229 230 236 241 public void 242 actionPerformed(java.awt.event.ActionEvent e) 243 { 244 Display to_server = the_context_.get_connection_to_server(); 247 248 if(to_server == null) 250 { 251 System.err.println("The demo1::Client::to_server receptacle is not set!"); 252 return; 253 } 254 255 to_server.print(name_ + ":" + text_.getText()); 257 } 258 } 259 | Popular Tags |