Skip to main content

'Set commands as buttons doesnt work for non-static show method of Dialog.

2 replies [Last post]
Joined: 2010-07-14

The objective is to show a dialog with three buttons in that
we intend to set the size and position of the dialog ourselves.
We have tried to achieve this using the non static show method
as below with no success :
final Dialog dialog = new Dialog(Title);
Label lbl = new Label("Name");

Command abc = new Command("abc");
Command def = new Command("def");
Command cancel = new Command("cancel");

// dialog.setCommandsAsButtons(true);

Command cmd = dialog.showDialog();

if (cmd == cmdOK || cmd == null) {
return "Good";
} else {
return "";

The commands show up as soft-button-commands and not as on-screen-buttons.
So we have abc and Menu as the two commands showing up!
Since we are stuck at getting the ui right, we haven't
been able to proceed with resizing and positioning the dialog.

As against this, the static show method as in following code works
just great but in that we can't set the size and position of the dialog:
// popup a dialog with three buttons: abc / def / cancel
Command[] cmds = new Command[3];
cmds[0] = new Command("abc");
cmds[1] = new Command("def);
cmds[2] = new Command("Cancel");

Command pressed ="Name",
"Something", cmds, Dialog.TYPE_INFO, null, 0,

if(pressed.equals(cmds[1])) {
// Do something
} else if(pressed.equals(cmds[0])) {
// Do some other thing

Could you all please help us get past the setCommandsAsButtons() to work
so we can try to reposition the dialog?

Thanks in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-11-07

That's by design.
Just add buttons to your dialog and create the button with a command instance. Look at the code for for example of how we implement the commands as buttons.

Joined: 2010-07-14

Thanks. We'll try this and post the code.