2017-02-20 11 views
1

私はダイアログボックスにテキストフィールドを持っています。私がそれに型押しをしようとすると、外に出るだけです。ここで何が起こったのですか?私はビデオをキャプチャしました。見てください。 https://youtu.be/HhwoPWJDG1Mテキストフィールド(Codenameone)のキーボードフォーカス問題

コード:

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

答えて

1

問題がautoDisposingからそれを維持showPopup()ダイアログを使用していないから来ています。 showPacked()またはshowStretched()のいずれかを使用し、その位置を定義し、falseにダイアログautoDispose()を設定します。

d.setAutoDispose(false); //reason dialog is disposing quickly 
d.setDisposeWhenPointerOutOfBounds(true); 
d.showPacked(BorderLayout.NORTH, true); 
関連する問題