51 |
import javax.swing.text.NavigationFilter; |
import javax.swing.text.NavigationFilter; |
52 |
|
|
53 |
/** |
/** |
54 |
|
* A text field that makes use of a formatter to display and edit a specific |
55 |
|
* type of data. The value that is displayed can be an arbitrary object. The |
56 |
|
* formatter is responsible for displaying the value in a textual form and |
57 |
|
* it may allow editing of the value. |
58 |
|
* |
59 |
|
* Formatters are usually obtained using an instance of |
60 |
|
* {@link AbstractFormatterFactory}. This factory is responsible for providing |
61 |
|
* an instance of {@link AbstractFormatter} that is able to handle the |
62 |
|
* formatting of the value of the JFormattedTextField. |
63 |
|
* |
64 |
* @author Michael Koch |
* @author Michael Koch |
65 |
|
* |
66 |
* @since 1.4 |
* @since 1.4 |
67 |
*/ |
*/ |
68 |
public class JFormattedTextField extends JTextField |
public class JFormattedTextField extends JTextField |
69 |
{ |
{ |
70 |
private static final long serialVersionUID = 5464657870110180632L; |
private static final long serialVersionUID = 5464657870110180632L; |
71 |
|
|
72 |
|
/** |
73 |
|
* An abstract base implementation for a formatter that can be used by |
74 |
|
* a JTextField. A formatter can display a specific type of object and |
75 |
|
* may provide a way to edit this value. |
76 |
|
*/ |
77 |
public abstract static class AbstractFormatter implements Serializable |
public abstract static class AbstractFormatter implements Serializable |
78 |
{ |
{ |
79 |
private static final long serialVersionUID = -5193212041738979680L; |
private static final long serialVersionUID = -5193212041738979680L; |
140 |
public abstract String valueToString (Object value) |
public abstract String valueToString (Object value) |
141 |
throws ParseException; |
throws ParseException; |
142 |
} |
} |
143 |
|
|
144 |
|
/** |
145 |
|
* Delivers instances of an {@link AbstractFormatter} for |
146 |
|
* a specific value type for a JFormattedTextField. |
147 |
|
*/ |
148 |
public abstract static class AbstractFormatterFactory |
public abstract static class AbstractFormatterFactory |
149 |
{ |
{ |
150 |
public AbstractFormatterFactory () |
public AbstractFormatterFactory () |