R
Robert Maas, see http://tinyurl.com/uh3t
Recently in thinking about an application I'd like to write, I realized
that it would be good to have the following kind of JComponent:
There's a sub-class of JPanel which contains a JTextField and a
JButton. The component has a list of validators for the text field.
Whenever the user types text into or otherwise modifies the text field,
the background color changes to yellow, to indicate it hasn't yet been
validated. Whenever the user starts to move the mouse, indicating
he/she is finished with editing there, or pauses for longer than some
threshold, the list of validators are run against the current contents
of the text field, each inside a try block, and the first that succeeds
causes the label to be changed to say what kind of syntax was
recognized (for example, integer, double float, string-literal,
s-expression, etc.) and causes the background of the editable text
field to turn light green or perhaps some selected color depending on
the type of data shown. But if all validators fail, the background goes
pink and the label goes *invalid* or somesuch. Then when editing
resumes, background goes yellow again and label goes invisible again.
When the text field is valid the button would be activated such that
pressing it would cause an action event whereby the parsed object from
the text field is entered onto the stack of a RPN calculator or other
practical use within the overall application. When the text field is
yellow (in-edit) or pink (invalid), the button would not be active.
This would be a bit of work to implement, so before I start, has this
already been done, where I should just copy what's already done and
build my overall application upon it? Or is it a new idea that I should
be the first to implement?
that it would be good to have the following kind of JComponent:
There's a sub-class of JPanel which contains a JTextField and a
JButton. The component has a list of validators for the text field.
Whenever the user types text into or otherwise modifies the text field,
the background color changes to yellow, to indicate it hasn't yet been
validated. Whenever the user starts to move the mouse, indicating
he/she is finished with editing there, or pauses for longer than some
threshold, the list of validators are run against the current contents
of the text field, each inside a try block, and the first that succeeds
causes the label to be changed to say what kind of syntax was
recognized (for example, integer, double float, string-literal,
s-expression, etc.) and causes the background of the editable text
field to turn light green or perhaps some selected color depending on
the type of data shown. But if all validators fail, the background goes
pink and the label goes *invalid* or somesuch. Then when editing
resumes, background goes yellow again and label goes invisible again.
When the text field is valid the button would be activated such that
pressing it would cause an action event whereby the parsed object from
the text field is entered onto the stack of a RPN calculator or other
practical use within the overall application. When the text field is
yellow (in-edit) or pink (invalid), the button would not be active.
This would be a bit of work to implement, so before I start, has this
already been done, where I should just copy what's already done and
build my overall application upon it? Or is it a new idea that I should
be the first to implement?