Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libUI / src / org / gvsig / gui / beans / swing / jFormattedTextFieldWithSpecificCaretPosition / JFormattedTextFieldWithSpecificCaretPosition.java @ 11620

History | View | Annotate | Download (4.16 KB)

1 10122 ppiqueras
package org.gvsig.gui.beans.swing.jFormattedTextFieldWithSpecificCaretPosition;
2
3
import java.io.Serializable;
4 10495 ppiqueras
import java.text.Format;
5 10122 ppiqueras
6
import javax.swing.JFormattedTextField;
7
8
import org.gvsig.gui.awt.event.specificCaretPosition.ISpecificCaretPosition;
9
import org.gvsig.gui.awt.event.specificCaretPosition.SpecificCaretPositionListeners;
10
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
52
/**
53
 * This class is a JFormattedTextField with two listeners that allow authomatically reset the caret
54
 *   position of this component to left (LEFT_POSITIONS), right (RIGHT_POSITIONS) or like JFormattedTextField (LIKE_JTEXTCOMPONENT) (do nothing).
55
 *   By default is to left.
56
 *
57
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
58
 */
59
public class JFormattedTextFieldWithSpecificCaretPosition extends JFormattedTextField implements ISpecificCaretPosition, Serializable {
60
        private static final long serialVersionUID = -8224060521711689694L;
61
62
        private int caretPositionMode;
63
64
        /**
65
         * @see JFormattedTextField#JFormattedTextField()
66
         */
67
        public JFormattedTextFieldWithSpecificCaretPosition() {
68
                super();
69
                caretPositionMode = LEFT_POSITIONS;
70
                initialize();
71
        }
72
73
        /**
74 10495 ppiqueras
         * @see JFormattedTextField#JFormattedTextField(javax.swing.JFormattedTextField.AbstractFormatter)
75
         */
76
        public JFormattedTextFieldWithSpecificCaretPosition(JFormattedTextField.AbstractFormatter formatter) {
77
                super(formatter);
78
                caretPositionMode = LEFT_POSITIONS;
79
                initialize();
80
        }
81
82
        /**
83
         * @see JFormattedTextField#JFormattedTextField(javax.swing.JFormattedTextField.AbstractFormatterFactory)
84
         */
85
        public JFormattedTextFieldWithSpecificCaretPosition(JFormattedTextField.AbstractFormatterFactory factory) {
86
                super(factory);
87
                caretPositionMode = LEFT_POSITIONS;
88
                initialize();
89
        }
90
91
        /**
92
         * @see JFormattedTextField#JFormattedTextField(javax.swing.JFormattedTextField.AbstractFormatterFactory, java.lang.Object)
93
         */
94
        public JFormattedTextFieldWithSpecificCaretPosition(JFormattedTextField.AbstractFormatterFactory factory, Object currentValue) {
95
                super(factory, currentValue);
96
                caretPositionMode = LEFT_POSITIONS;
97
                initialize();
98
        }
99
100
        /**
101
         * @see JFormattedTextField#JFormattedTextField()
102
         */
103
        public JFormattedTextFieldWithSpecificCaretPosition(Format format) {
104
                super(format);
105
                caretPositionMode = LEFT_POSITIONS;
106
                initialize();
107
        }
108
109
        /**
110
         * @see JFormattedTextField#JFormattedTextField(java.lang.Object)
111
         */
112
        public JFormattedTextFieldWithSpecificCaretPosition(Object value) {
113
                super(value);
114
                caretPositionMode = LEFT_POSITIONS;
115
                initialize();
116
        }
117
118
        /**
119 10122 ppiqueras
         * This method adds three listeners to this component:
120
         */
121
        private void initialize() {
122
                SpecificCaretPositionListeners.setListeners(this);
123
        }
124
125
        /*
126
         *  (non-Javadoc)
127
         * @see org.gvsig.gui.awt.event.ISpecificCaretPosition#getCaretPositionMode()
128
         */
129
        public int getCaretPositionMode() {
130
                return caretPositionMode;
131
        }
132
133
        /*
134
         *  (non-Javadoc)
135
         * @see org.gvsig.gui.awt.event.ISpecificCaretPosition#setCaretPositionMode(int)
136
         */
137
        public void setCaretPositionMode(int caretPositionMode) {
138
                this.caretPositionMode = caretPositionMode;
139
        }
140
}