01: package examples;
02:
03: import java.awt.event.*;
04: import java.util.logging.*;
05: import javax.swing.*;
06: import vicazh.hyperpool.*;
07: import vicazh.hyperpool.Start;
08:
09: public class IExampleService extends IService implements ItemListener {
10:
11: private JTextArea area;
12:
13: private AbstractButton buttonClient;
14:
15: private AbstractButton buttonServer;
16:
17: /**
18: * @param name
19: * service name
20: * @param area
21: * text area
22: * @param buttonClient
23: * client button
24: * @param buttonServer
25: * server button
26: */
27: public IExampleService(String name, JTextArea area,
28: AbstractButton buttonClient, AbstractButton buttonServer) {
29: super (ExampleServiceMBean.class, name);
30: this .area = area;
31: this .buttonClient = buttonClient;
32: buttonClient.addItemListener(this );
33: this .buttonServer = buttonServer;
34: buttonServer.addItemListener(this );
35: }
36:
37: public void itemStateChanged(ItemEvent e) {
38: AbstractButton source = (AbstractButton) e.getItemSelectable();
39: try {
40: if (source == buttonClient)
41: setAttribute(ExampleServiceMBean.CLIENT, source
42: .isSelected());
43: else
44: setAttribute(ExampleServiceMBean.SERVER, source
45: .isSelected());
46: } catch (Exception ex) {
47: Start.logger.log(Level.SEVERE, ex.getMessage(), ex);
48: }
49: }
50:
51: protected void otherNotification(String type, Object value) {
52: if (type.equals(ExampleServiceMBean.CLIENT))
53: buttonClient.setSelected((Boolean) value);
54: else if (type.equals(ExampleServiceMBean.SERVER))
55: buttonServer.setSelected((Boolean) value);
56: else if (type.equals(ExampleServiceMBean.PRINT))
57: area.append((String) value);
58: }
59: }
|