Skip to main content

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

2 replies [Last post]
kaprasanna
Offline
Joined: 2010-07-14
Points: 0

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");
dialog.addComponent(lbl);

Command abc = new Command("abc");
Command def = new Command("def");
Command cancel = new Command("cancel");
dialog.addCommand(abc);
dialog.addCommand(def);
dialog.addCommand(cancel);

Dialog.setCommandsAsButtons(true);
// 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");

Dialog.setCommandsAsButtons(true);
Command pressed = Dialog.show("Name",
"Something", cmds, Dialog.TYPE_INFO, null, 0,
CommonTransitions.createFade(1000));

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.
vprise
Offline
Joined: 2003-11-07
Points: 0

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

kaprasanna
Offline
Joined: 2010-07-14
Points: 0

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