swingwtx.custom.validation
Class ValidationGroup

java.lang.Object
  extended byswingwtx.custom.validation.ValidationGroup

public class ValidationGroup
extends java.lang.Object

This isn't a real Swing class at all! This is a useful class that someone suggested we include from C# WinForms! After all, if we're going to make a new GUI API that matches Swing there's nothing wrong with including new bits and pieces if they're useful :) Besides, I hear the JGoodies people are charging for an implementation of this - only took me a couple of hours to implement! This class allows you to monitor validation errors. Each of the validatable components supports a new event listener called "ValidateListener", passing in a ValidateEvent - your code should decide whether the component is ok and set true or false with a message. The same component can be a member of different validation groups, as each validation group allows one stock icon. I had a long think about this and decided the best way to deal with this was to make some new versions of the regular components you might want to validate. They are all prefixed with the word "Validatable" - eg: ValidatableJTextField, ValidatableJTextArea.


Field Summary
protected  java.util.Vector components
           
protected  java.lang.String errorMessage
          Last seen error message from a component
protected  ImageIcon pImage
           
 
Constructor Summary
ValidationGroup()
          Creates an error provider with the default error icon
ValidationGroup(ImageIcon image)
           
 
Method Summary
 void add(ValidatableComponent c)
           
 boolean checkValidation()
          Calls the validation routines for each component this ValidationGroup is managing
 void clearErrors()
          Clears all error messages and icons from all components this ValidationGroup is managing.
 java.lang.String getErrorMessage()
           
 ImageIcon getIcon()
           
 void remove(ValidatableComponent c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pImage

protected ImageIcon pImage

components

protected java.util.Vector components

errorMessage

protected java.lang.String errorMessage
Last seen error message from a component

Constructor Detail

ValidationGroup

public ValidationGroup()
Creates an error provider with the default error icon


ValidationGroup

public ValidationGroup(ImageIcon image)
Method Detail

add

public void add(ValidatableComponent c)

remove

public void remove(ValidatableComponent c)

getIcon

public ImageIcon getIcon()

getErrorMessage

public java.lang.String getErrorMessage()

checkValidation

public boolean checkValidation()
Calls the validation routines for each component this ValidationGroup is managing

Returns:
true if validation is ok, otherwise returns false. Call getErrorMessage() for the last error message from a component.

clearErrors

public void clearErrors()
Clears all error messages and icons from all components this ValidationGroup is managing.