我想在我的 J2ME LWUIT 应用程序中显示一个对话框。在对话框中,我可以添加文本区域和按钮。现在我想在单击按钮时关闭对话框。我的代码在下面,我想在按下“确定”按钮的同时关闭按钮。
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);