1 26 27 package org.objectweb.ccm.demo2.cif; 28 29 import org.objectweb.ccm.demo2.*; 30 31 44 45 public class ProducerImpl 46 extends org.objectweb.ccm.demo2.ProducerSessionComposition.ComponentImpl 47 implements java.awt.event.ActionListener 48 { 49 55 56 private String name_; 57 58 59 private javax.swing.JFrame frame_; 60 61 62 private javax.swing.JList list_; 63 64 70 71 public 72 ProducerImpl() 73 { 74 } 75 76 82 88 94 100 public void 101 configuration_complete () 102 throws org.omg.Components.InvalidConfiguration 103 { 104 if(name_ == null) 106 throw new org.omg.Components.InvalidConfiguration(); 107 108 110 frame_ = new javax.swing.JFrame (name_ + "'s Producer GUI"); 112 frame_.setSize(400, 300); 114 115 String [] data = { 117 "apple", "pear", "carrot", "corn", "milk", "orange" , "beer", 118 "radish", "beans", "pumpkin", "salad", "worm", "potato", "nothing" 119 }; 120 list_ = new javax.swing.JList (data); 121 122 javax.swing.JButton button = new javax.swing.JButton ("Do crop"); 124 button.addActionListener(this); 125 126 javax.swing.JPanel panel = new javax.swing.JPanel ( 128 new java.awt.BorderLayout () 129 ); 130 frame_.getContentPane().add(panel); 131 panel.add(new javax.swing.JScrollPane (list_), 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 name(String n) 171 { 172 name_ = n; 173 174 if (frame_ != null) 175 frame_.setTitle(name_ + "'s Producer GUI"); 176 } 177 178 183 public String 184 name() 185 { 186 return name_; 187 } 188 189 195 200 public void 201 actionPerformed(java.awt.event.ActionEvent e) 202 { 203 if (list_.isSelectionEmpty()) 204 return; 205 206 Object [] texts = list_.getSelectedValues(); 207 for (int i=0; i<texts.length; i++) 208 { 209 get_context().push_crop(new FoodImpl( (String )texts[i] )); 210 } 211 212 list_.clearSelection(); 213 } 214 } 215 | Popular Tags |