1 22 package org.objectweb.petals.binding.axis2.client; 23 24 import java.awt.GridLayout ; 25 import java.awt.event.ActionEvent ; 26 import java.awt.event.ActionListener ; 27 28 import javax.swing.BorderFactory ; 29 import javax.swing.JButton ; 30 import javax.swing.JLabel ; 31 import javax.swing.JPanel ; 32 import javax.swing.JScrollPane ; 33 import javax.swing.JTextArea ; 34 import javax.swing.JTextField ; 35 import javax.swing.WindowConstants ; 36 import javax.swing.border.BevelBorder ; 37 38 39 47 public class AxisGUIClient extends javax.swing.JFrame { 48 49 private static final long serialVersionUID = -10075363478608221L; 50 51 private JPanel jPanel1; 52 53 private JPanel jPanel4; 54 55 private JScrollPane jScrollPane1; 56 57 private JTextArea out; 58 59 private JTextArea in; 60 61 private JTextField operation; 62 63 private JTextField service; 64 65 private JTextField host; 66 67 private JTextField port; 68 69 private JButton jButton1; 70 71 private JLabel jLabel2; 72 73 private JLabel jLabel1; 74 75 private JLabel jLabel3; 76 77 private JLabel jLabel4; 78 79 private JPanel jPanel2; 80 81 public AxisGUIClient() { 82 super(); 83 initGUI(); 84 } 85 86 public static void main(String [] args) { 87 AxisGUIClient inst = new AxisGUIClient(); 88 inst.setVisible(true); 89 } 90 91 105 public static String send(String host, String port, String service, 106 String operation, Object [] parameters) { 107 108 114 String result = new String (); 115 116 try { 117 145 146 } catch (Exception ex) { 147 ex.printStackTrace(); 148 return ex.toString(); 149 } 150 151 152 180 return result; 181 } 182 183 public void setResponse(String text) { 184 out.append(text + "\n"); 185 } 186 187 191 private void initGUI() { 192 try { 193 GridLayout thisLayout = new GridLayout (3, 1); 194 thisLayout.setHgap(5); 195 thisLayout.setVgap(5); 196 thisLayout.setColumns(1); 197 thisLayout.setRows(3); 198 getContentPane().setLayout(thisLayout); 199 setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 200 this.setPreferredSize(new java.awt.Dimension (490, 316)); 201 jPanel1 = new JPanel (); 202 GridLayout jPanel1Layout = new GridLayout (5, 2); 203 jPanel1Layout.setHgap(5); 204 jPanel1Layout.setVgap(5); 205 jPanel1Layout.setColumns(2); 206 jPanel1Layout.setRows(5); 207 jPanel1.setLayout(jPanel1Layout); 208 getContentPane().add(jPanel1); 209 jPanel1.setSize(500, 400); 210 jPanel1.setBorder(BorderFactory 211 .createEtchedBorder(BevelBorder.LOWERED)); 212 jPanel1.setPreferredSize(new java.awt.Dimension (490, 400)); 213 jLabel1 = new JLabel (); 214 jPanel1.add(jLabel1); 215 jLabel1.setText("service"); 216 jLabel1.setPreferredSize(new java.awt.Dimension (113, 39)); 217 service = new JTextField (); 218 jLabel1.add(service); 219 service.setText("{http://petals.objectweb.org/}HelloworldService"); 220 service.setBounds(245, 0, 231, 21); 221 jLabel2 = new JLabel (); 222 jPanel1.add(jLabel2); 223 jLabel2.setText("operation"); 224 jLabel2.setPreferredSize(new java.awt.Dimension (132, 39)); 225 operation = new JTextField (); 226 jLabel2.add(operation); 227 operation.setText("printMessage"); 228 operation.setBounds(245, 0, 231, 21); 229 jLabel3 = new JLabel (); 230 jPanel1.add(jLabel3); 231 jLabel3.setText("host"); 232 jLabel3.setPreferredSize(new java.awt.Dimension (113, 39)); 233 host = new JTextField (); 234 jLabel3.add(host); 235 host.setText("127.0.0.1"); 236 host.setBounds(245, 0, 231, 21); 237 jLabel4 = new JLabel (); 238 jPanel1.add(jLabel4); 239 jLabel4.setText("port"); 240 jLabel4.setPreferredSize(new java.awt.Dimension (113, 39)); 241 port = new JTextField (); 242 jLabel4.add(port); 243 port.setText("8084"); 244 port.setBounds(245, 0, 231, 21); 245 jPanel4 = new JPanel (); 246 getContentPane().add(jPanel4); 247 jPanel4.setBorder(BorderFactory 248 .createEtchedBorder(BevelBorder.LOWERED)); 249 jPanel4.setPreferredSize(new java.awt.Dimension (490, 130)); 250 jButton1 = new JButton (); 251 jPanel4.add(jButton1); 252 jButton1.setText("Send request)"); 253 jButton1.setPreferredSize(new java.awt.Dimension (197, 39)); 254 jButton1.addActionListener(new ActionListener () { 255 public void actionPerformed(ActionEvent evt) { 256 send(); 257 } 258 }); 259 jPanel2 = new JPanel (); 260 GridLayout jPanel2Layout = new GridLayout (1, 1); 261 jPanel2Layout.setHgap(5); 262 jPanel2Layout.setVgap(5); 263 jPanel2Layout.setColumns(1); 264 jPanel2Layout.setRows(1); 265 jPanel2.setLayout(jPanel2Layout); 266 getContentPane().add(jPanel2); 267 jPanel2.setBorder(BorderFactory 268 .createEtchedBorder(BevelBorder.LOWERED)); 269 jPanel2.setSize(492, 150); 270 jPanel2.setPreferredSize(new java.awt.Dimension (480, 100)); 271 jScrollPane1 = new JScrollPane (); 272 jPanel2.add(jScrollPane1); 273 in = new JTextArea (); 274 jScrollPane1.setPreferredSize(new java.awt.Dimension (392, 200)); 275 jScrollPane1.setViewportView(in); 276 pack(); 277 this.setSize(490, 316); 278 } catch (Exception e) { 279 e.printStackTrace(); 280 } 281 } 282 283 287 private void send() { 288 289 Object [] params = {"coucou"}; 290 in.setText(AxisGUIClient.send(host.getText(), port.getText(), service 291 .getText(), operation.getText(), params)); 292 } 293 294 331 } 332 | Popular Tags |