-
FEATURED COMPONENTS
First time here? Check out the FAQ!
if the textbox's value don't match its constriant properties
the textbox will show a errormessage right of it.
when i do something else
just like checking user's input in the database
can i show a error message like this?
You can have your own implementation of Constraint:
public class MyConstraint implements Constraint, java.io.Serializable {...
and override the validate method:
@Override public void validate(Component comp, Object value) throws WrongValueException { if (comp instanceof Textbox) { String enteredValue = (String) value; if (!enteredValue.isEmpty()) { //your logic here } else { throw new WrongValueException(comp, "Your wrong value label here"); } } }
then set your Constraint to the textbox: tb.setConstraint(new MyConstraint());
Asked: 2011-10-08 04:48:59 +0800
Seen: 290 times
Last updated: Oct 08 '11