将垂直滚动条放在luwit形式

时间:2011-05-09 11:57:23

标签: java java-me lwuit

我们如何将垂直滚动条放在lwuit形式中。 我尝试过setScrollableY(true)方法,但它不起作用。

我的代码在这里。

import com.sun.lwuit.*;
import com.sun.lwuit.events.ActionListener;

public class ChangePWD extends Form {

    private Label lblold,  lblnew1,  lblnew2;
    private TextField txtOldPwd,  txtNewpwd1,  txtNewpwd2;
    private Command cmdClose,  cmdSave;

    ChangePWD() {
        super("Change Password");
        setScrollableY(true);
        lblold = new Label("Enter Old Password");
        txtOldPwd = new TextField("");
        txtOldPwd.setConstraint(TextField.PASSWORD);

        lblnew1 = new Label("Enter New Password");
        txtNewpwd1 = new TextField("");
        txtNewpwd1.setConstraint(TextField.PASSWORD);

        lblnew2 = new Label("Confirm New Password");
        txtNewpwd2 = new TextField("");
        txtNewpwd2.setConstraint(TextField.PASSWORD);


        cmdClose = new Command("Close");
        cmdSave = new Command("Save");


        addCommand(cmdSave);
        addCommand(cmdClose);
        addComponent(lblold);
        addComponent(txtOldPwd);
        addComponent(lblnew1);
        addComponent(txtNewpwd1);
        addComponent(lblnew2);
        addComponent(txtNewpwd2);

    }

    public static ChangePWD createChangePWD(ActionListener l) {
        ChangePWD p = new ChangePWD();
        p.addCommandListener(l);
        return p;
    }

    public Command getSave() {
        return cmdSave;
    }

    public Command getClose() {
        return cmdClose;
    }

    public String getTxtOldpwd(){
        return txtOldPwd.getText();
    }

    public String getTxtNewpwd1(){
        return txtNewpwd1.getText();
    }
    public String getTxtNewpwd2(){
        return txtNewpwd2.getText();
    }
}

如果您有任何想法,请建议我。

谢谢。

1 个答案:

答案 0 :(得分:0)

添加

setHeigth(1) ;

之前

setScrollableY(true) ;

这对我有用。我仍然不明白为什么。

Yannik