View Javadoc

1   /***
2    * Created on Jun 29, 2005, Copyright UC Regents
3    */
4   package org.telscenter.pas.util;
5   
6   import java.util.logging.Logger;
7   
8   import java.awt.BorderLayout;
9   import java.awt.Container;
10  import java.awt.event.ActionEvent;
11  import java.awt.event.ActionListener;
12  import java.io.IOException;
13  import java.net.SocketException;
14  import java.net.UnknownHostException;
15  
16  import javax.swing.JFrame;
17  import javax.swing.JLabel;
18  import javax.swing.JTextField;
19  
20  //import org.telscenter.pas.messaging.PasCommandRepeater;
21  
22  import net.sf.sail.common.messaging.multicast.Multicaster;
23  
24  /***
25   * @author turadg
26   */
27  public class ClassroomShouter extends JFrame {
28  	/***
29  	 * Logger for this class
30  	 */
31  	private static final Logger logger = Logger
32  			.getLogger(ClassroomShouter.class.getName());
33  
34  	Multicaster multicaster;
35  
36  	/***
37  	 * 
38  	 */
39  	public ClassroomShouter() {
40  		super("Classroom Shouter");
41  		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
42  
43  		try {
44  			multicaster = new Multicaster();
45  		} catch (UnknownHostException e) {
46  			// TODO Auto-generated catch block
47  			logger.severe("exception: " + e); //$NON-NLS-1$
48  		} catch (SocketException e) {
49  			// TODO Auto-generated catch block
50  			logger.severe("exception: " + e); //$NON-NLS-1$
51  		}
52  
53  		Container content = getContentPane();
54  
55  		content.setLayout(new BorderLayout());
56  		JLabel label = new JLabel();
57  		label.setText("Type a message to shout and hit enter to send");
58  		content.add(label, BorderLayout.NORTH);
59  
60  /*		JTextField textField = new JTextField(PasCommandRepeater.COMMANDS_NOTIFY +  " this works!");
61  		textField.addActionListener(new ActionListener() {
62  
63  			public void actionPerformed(ActionEvent e) {
64  				try {
65  					multicaster.shout(e.getActionCommand());
66  				} catch (IOException e1) {
67  					// TODO Auto-generated catch block
68  					logger.severe("ActionEvent -  : exception: " + e1); //$NON-NLS-1$
69  				}
70  			}
71  		});
72  		content.add(textField, BorderLayout.CENTER);
73  */		pack();
74  	}
75  
76  	public static void main(String[] args) throws IOException {
77  		ClassroomShouter t = new ClassroomShouter();
78  		t.setVisible(true);
79  	}
80  
81  }