01: package vicazh.hyperpool.stream.net.http;
02:
03: import javax.swing.*;
04: import javax.swing.event.*;
05: import vicazh.hyperpool.*;
06: import vicazh.hyperpool.Start;
07: import java.awt.event.*;
08: import java.util.logging.*;
09:
10: /**
11: * The graphic document service
12: *
13: * @author Victor Zhigunov
14: * @version 0.4.0
15: */
16: public class IDocumentService extends IService implements
17: DocumentServiceMBean, ActionListener, DocumentListener {
18: private JTextField text;
19:
20: private JButton buttonOK;
21:
22: /**
23: * @param name
24: * service name
25: * @param text
26: * text field
27: * @param buttonOK
28: * OK button
29: */
30: public IDocumentService(String name, JTextField text,
31: JButton buttonOK) {
32: super (DocumentServiceMBean.class, name);
33: text.getDocument().addDocumentListener(this );
34: this .text = text;
35: buttonOK.setEnabled(false);
36: buttonOK.addActionListener(this );
37: this .buttonOK = buttonOK;
38: }
39:
40: public void actionPerformed(ActionEvent e) {
41: buttonOK.setEnabled(false);
42: try {
43: setAttribute(DocumentServiceMBean.URL, text.getText());
44: } catch (Exception ex) {
45: Start.logger.log(Level.SEVERE, ex.getMessage(), ex);
46: }
47: }
48:
49: public void insertUpdate(DocumentEvent e) {
50: update();
51: }
52:
53: public void removeUpdate(DocumentEvent e) {
54: update();
55: }
56:
57: public void changedUpdate(DocumentEvent e) {
58: update();
59: }
60:
61: private void update() {
62: buttonOK.setEnabled(true);
63: }
64:
65: protected void otherNotification(String type, Object value) {
66: text.setText((String) value);
67: }
68: }
|