文本字段中的键盘焦点问题(Codenameone)

文本字段中的键盘焦点问题(Codenameone),codenameone,Codenameone,我在对话框中有一个文本字段。当我试着在里面输入smth时,它就消失了。刚才发生了什么。我已经抓拍了视频。请看一看 代码: super(new BoxLayout(BoxLayout.Y_AXIS)); setScrollableY(false); Container mainContainer = new Container(new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER)); add(mainContainer); Label logo

我在对话框中有一个文本字段。当我试着在里面输入smth时,它就消失了。刚才发生了什么。我已经抓拍了视频。请看一看

代码:

super(new BoxLayout(BoxLayout.Y_AXIS));
setScrollableY(false);
Container mainContainer = new Container(new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER));
add(mainContainer);
Label logo = new Label();
mainContainer.addComponent(BorderLayout.NORTH, logo);
Button forgotPassword = new Button("FORGOT PASSWORD");
- - - - - - - - - - - -
//r components added to main form
- - - - - - - - - - - -
Container centerContainer = BoxLayout.encloseY(userNameField, passwordSection, forgotPassword);
mainContainer.add(BorderLayout.CENTER, centerContainer);


TableLayout tl = new TableLayout(1, 2);
Container passwordSection = new Container(tl);
passwordSection.add(tl.createConstraint().
    widthPercentage(80),passwordField).
    add(tl.createConstraint().verticalAlign(Component.CENTER).widthPercentage(19), sendButton);

**//this is the dialog box where problem exists**
forgotPassword.addActionListener(e -> {
    Dialog d = new Dialog();
    TextField emailTextField = new TextField();
    emailTextField.setHint("Enter your email here");
    d.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    d.add(emailTextField);
    Button submit = new Button("Submit");
    d.add(submit);
    d.showPopupDialog(logo);
});

问题来自于使用
showPopup()
对话框而没有阻止其自动处理。使用
showPacked()
showStretch()
之一并定义其位置,然后将对话框
autoDispose()
设置为false:

d.setAutoDispose(false); //reason dialog is disposing quickly
d.setDisposeWhenPointerOutOfBounds(true);
d.showPacked(BorderLayout.NORTH, true);