Hide Dialog from inside in LWUIT

488 Views Asked by At

I have created a Dialog with two buttons Yes, No, and then I have add action listener to them, my problem is that I want no button to hide the Dialog that I have created

the code is looks like:

dialog = new Dialog(title);
        dialog.setDialogType(Dialog.TYPE_CONFIRMATION);

        ta = new TextArea(text);
        ta.getStyle().setBorder(Border.createEmpty());
        ta.setEditable(false);
        yesCommand = new Button("YES");
        noCommand = new Button("NO");

        yesCommand.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent ae) {
                LGBMainMidlet.getLGBMidlet().notifyDestroyed();
            }
        });

        noCommand.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent ae) {
                Logger.Log("Bye Bye");
                dialog = null;
                System.gc();
            }
        });

        dialog.addComponent(ta);
        dialog.addComponent(yesCommand);
        dialog.addComponent(noCommand);
        dialog.show();

the code is not working for me, can anyone told me what is the problem?

B.N. I have used dialog.dispose(), but it exit the whole application

2

There are 2 best solutions below

1
Shai Almog On BEST ANSWER

Dialog.dispose() does not exit the whole application, it just closes the dialog. If you have nothing in your application you might see nothing if you dispose the dialog.

0
Ayuya On

It is better to use dialog.setTimeout(1000); the number show the time limit the dialog box wait in milliseconds. So by doing this you can exit the dialog form automatically.