Re: validation in gui and error handling
harryos <oswald.harry@gmail.com> writes:
I have a gui application which asks the user to input two numerical
values in text fields.
Most probably ?numerals? not ?values? - by my terminology.
One must be an integer and the other should be a decimal .
Usually the decimal system also is used for integral numerals.
So this is not a specification precise enough for a coder
to start to work from it.
So,I thought I would do the validation in the model and let controller
ask the view to display appropriate messages.
Code can be structured by a recursive application of the
MVC architecture:
You want a control to get two numerals from the user.
From the external point of view, this control is just a part
of the view and always will deliver a valid input (i.e.,
either two numerals, or, possibly, a ?CANCELED? value.)
From the internal view of this control, it is made of a model,
a view, and a controller, itself.
This is the first time I am doing a gui app in java.I am not
sure this is the correct way of dealing with the validations
and error displays.If someone can point me to the right way
,it will help me a lot.
Read GUI code written by successful programmers before
writing your own. For example, study the sourcecode of some
Swing controls, for example, the JFileChooser.