1 26 27 package org.objectweb.ccm.demo3.cif; 28 29 import org.objectweb.ccm.demo3.*; 30 31 44 public class ClientImpl 45 extends org.objectweb.ccm.demo3.ClientSessionComposition.ComponentImpl 46 implements java.awt.event.ActionListener 47 { 48 54 55 private String name_; 56 57 58 private javax.swing.JFrame frame_; 59 60 61 private javax.swing.JTextField text_; 62 63 69 70 public 71 ClientImpl() 72 { 73 } 74 75 81 87 93 99 public void 100 configuration_complete() 101 throws org.omg.Components.InvalidConfiguration 102 { 103 if(name_ == null) 105 throw new org.omg.Components.InvalidConfiguration(); 106 107 if(get_context().get_connection_the_service() == null) 109 throw new org.omg.Components.InvalidConfiguration(); 110 111 113 frame_ = new javax.swing.JFrame (name_ + "'s Client GUI"); 115 frame_.setSize(400, 300); 117 118 text_ = new javax.swing.JTextField ("", 1); 120 121 javax.swing.JButton button = new javax.swing.JButton ("Print Text"); 123 button.addActionListener(this); 124 125 javax.swing.JPanel panel = new javax.swing.JPanel ( 127 new java.awt.BorderLayout () 128 ); 129 frame_.getContentPane().add(panel); 130 panel.add(new javax.swing.JScrollPane (text_), 131 java.awt.BorderLayout.CENTER); 132 panel.add(button, java.awt.BorderLayout.SOUTH); 133 frame_.pack(); 134 frame_.show(); 135 } 136 137 143 148 public void 149 ccm_remove() 150 throws org.omg.Components.CCMException 151 { 152 frame_.dispose(); 154 frame_ = null; 155 } 156 157 163 168 public void 169 name(String n) 170 { 171 name_ = n; 172 173 if (frame_ != null) 174 frame_.setTitle(name_ + "'s Client GUI"); 175 } 176 177 182 public String 183 name() 184 { 185 return name_; 186 } 187 188 194 199 public void 200 actionPerformed(java.awt.event.ActionEvent e) 201 { 202 Service service = get_context().get_connection_the_service(); 205 206 if(service == null) 208 { 209 System.err.println("The demo3::Client::the_service receptacle is not set!"); 210 return; 211 } 212 213 service.display(name_ + ":" + text_.getText()); 215 } 216 } 217 | Popular Tags |