01: /*
02: * Copyright (C) 2007 Jared Alexander Spigner
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: * jspigner@openjx.org
19: *
20: * JXDocumentAdapter.java
21: *
22: * Created on June 13, 2007, 11:11 PM
23: *
24: */
25:
26: package org.openjx.jx;
27:
28: import javax.swing.event.DocumentEvent;
29: import javax.swing.event.DocumentListener;
30:
31: import org.openjx.core.JXTranslator;
32:
33: /**
34: * This is an adapter class to the DocumentListener interface. It allows us
35: * to bind swing values of the document to JX properties and vice versa.
36: *
37: * @author Jared Spigner
38: */
39: public class JXDocumentAdapter implements DocumentListener {
40: /** This is a reference to the JXTranslator. */
41: public JXTranslator jxTranslator;
42:
43: /** Creates a new instance of JXDocumentAdapter */
44: public JXDocumentAdapter() {
45: this .jxTranslator = new JXTranslator();
46: }
47:
48: /**
49: * This method handles document attribute change events.
50: *
51: * @param evt is the event that was fired off.
52: */
53: public void changedUpdate(DocumentEvent evt) {
54: }
55:
56: /**
57: * This method handles document insert change events.
58: *
59: * @param evt is the event that was fired off.
60: */
61: public void insertUpdate(DocumentEvent evt) {
62: }
63:
64: /**
65: * This method handles document removal change events.
66: *
67: * @param evt is the event that was fired off.
68: */
69: public void removeUpdate(DocumentEvent evt) {
70: }
71:
72: /**
73: * Without this method and the other update method we can not access the
74: * document text or properties without getting a
75: * java.lang.IllegalStateException: Attempt to mutate in notification. The
76: * reason is because JAVA version 1.4 and onward, however, will not allow
77: * us to set modify the contents of the textField while we are handling one
78: * of its document events. So, we will need to make the following
79: * changes:
80: * 1. avoid setting the text field's text within the update() whenever we call
81: * update() from a DocumentListener
82: * 2. remove/add the document listener at the start/end of the update()
83: * method.
84: */
85: public void update() {
86: }
87:
88: /**
89: * Value is just a value used to differentiate between the update method
90: * and this update method which is called by the one with no arguments.
91: */
92: public void update(boolean value) {
93: }
94: }
|