gpt4 book ai didi

java - 如何验证 SWT 表单?

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:41:30 24 4
gpt4 key购买 nike

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);

}
}

});

您好,我正在 eclipse 中使用 SWT 创建表单 谁能告诉我如何验证上面的表单条目是该示例代码..实际上我想验证密码字段,它的最小长度应该为 6。如何做这个请回复。

最佳答案

您可以使用消息管理器,如 Eclipse Form 中所述文章。

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.

alt text


关于具体的问题,你可以看看这个问题的类似实现,比如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

关于java - 如何验证 SWT 表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2721385/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com