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 form using SWT in eclipse can anyone tell me how to validate that form entry above is the sample code of that..actually 开发者_开发百科i want to validate password field it should be minimum length of 6.How to do this please reply.
You can use a Message Manager, as described in Eclipse Form article.
As discussed above, support has been added to show messages in the form heading. To make the handling of multiple messages within a form easier, a message manager has been made available in 3.3 through the
IManagedForm
interface. The manager is provided as an interface (IMessageManager
).The message manager will track multiple messages for the user at a time and will show text-based on the most severe message present at any given time (
ERROR > WARNING > INFO
).
It also provides the ability, when adding a message, to associate a control with it. If this is done, the message manager will decorate the specified control with an image appropriate to the message type.
Regarding the specific issue, you can look at similar implementations of this problem, like the 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
精彩评论