I want to show a Dialog box in my J2ME LWUIT application. In the dialog box i am able to add text area and buttons. Now i wan to close the dialog when i click the button. My code is below and i want to close the button while pressing "ok" button.
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);
Why you dont use dialog and adding all components on him?
if you use that you can only write in action premford function:
okbut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae)
{
dialogName.dispose();
}
}
);
You can't dispose Container. the only thing that you can do is to give him null and excute the form again.