0
我想在我的J2ME LWUIT應用程序中顯示一個對話框。在對話框中,我可以添加文本區域和按鈕。現在我想單擊按鈕時關閉對話框。我的代碼在下面,我想關閉按鈕,同時按下「確定」按鈕。帶自定義按鈕的對話框,LWUIT,J2ME
Container dispback = new Container(new BoxLayout(BoxLayout.Y_AXIS));
TextArea textArea = new TextArea(Message); //pass the alert text here
textArea.setFocusable(false);
textArea.setEditable(false);
Font fnt=Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM);
textArea.getStyle().setFont(fnt);
textArea.getSelectedStyle().setBorder(null);
textArea.getUnselectedStyle().setBorder(null);
textArea.getStyle().setFgColor(0xFF0000);
textArea.getStyle().setBgTransparency(0);
textArea.setIsScrollVisible(false);
textArea.getStyle().setMargin(20,0,0,0);
Button okbut = new Button("OK");
//okbut.setAlignment(Component.CENTER);
okbut.getStyle().setFont(fnt);
okbut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae)
{
**//How to close my dialog here**
}
});
dispback.addComponent(textArea);
okbut.setWidth(10);
dispback.addComponent(okbut);
Dialog.show("SnorkelOTP-Info", dispback, null,0,null);
感謝您的回覆。我目前只使用該模型。但問題是,當我調用「dialogName..show(」SnorkelOTP-Info「,撤銷,null,0,TransotionObj);」 ,「Netbeans」顯示警告「訪問靜態方法顯示」。 – DAC84
如果你進入Lwuit類對話框。你可以看到大多數函數表示(...)除了它們之外都是靜態的。 – neb1
所以我認爲我們應該使用「Dialog.show()」而不是「dialogName.show()」來調用這些函數。我對麼?。如果我是正確的,那麼我怎麼能使用「dialogName.dispose()」。 – DAC84