How do I validate a SWT form?
Label label1 = new Label(container, SWT.NULL);
label1.setText("Enter the Password ");
text1 = new Text(container, SWT.BORDER | SWT.PASSWORD);
text1.setText("");
text1.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
if (!text5.getText().isEmpty()) {
setPageComplete(false);
}
}
});
Hi I am creating a form using SWT in eclipse, can anyone tell me how to check that the form entry above is a sample code of this. Actually I want to check the password field, it should be of minimum length 6. How to do it answer.
a source to share
You can use the message manager as described in the Eclipse Form article .
As discussed above, support has been added for displaying messages in the form header. To make it easier to handle multiple messages in a form, a message dispatcher was available in 3.3 through an interface
IManagedForm
. The manager is provided as an interface (IMessageManager
).The message manager will track multiple messages for the user at the same time and will display text based on the most serious message present at any given time (
ERROR > WARNING > INFO
).
It also provides the ability to bind a control to it when you add a message. If this is done, the message dispatcher will decorate the specified control with an image that matches the message type.

For a specific problem, you can look at similar implementations of this problem, for example org.eclipse.team.internal.ccvs.ui.wizards.ConfigurationWizardMainPage
class :
// Password
createLabel(g, CVSUIMessages.ConfigurationWizardMainPage_password);
passwordText = createPasswordField(g);
passwordText.addListener(SWT.Modify, listener);
Listener listener = new Listener() {
public void handleEvent(Event event) {
if (event.widget == passwordText) {
// check its length
a source to share