PDA

View Full Version : Custom buttons with MessageBox



hbonpard
22 Jul 2010, 5:18 AM
Hi,

i am trying to create a customized messagebox in this way:


public void displayError(String title, String message, Listener<MessageBoxEvent> callback){
MessageBox box = new MessageBox();
box.setButtons(MessageBox.YESNOCANCEL);
box.getDialog().cancelText="sometext";
box.setIcon(MessageBox.WARNING);
box.setTitle(title);
box.setMessage(message);
box.addCallback(callback);
box.show();

}

I don't know why it is not working: the cancelText is always "cancel" and not "sometext" as i setted it.

Can somebody tell me what i am doing wrong?

Thank you for every help!!

sven
22 Jul 2010, 5:20 AM
Try to first set the canceltext and than create the buttons

hbonpard
22 Jul 2010, 5:37 AM
hi Sven,

i tried it but it also doesn't work.

that is my new code:


MessageBox box = new MessageBox();
box.setTitle(title);
box.setMessage(message);
box.addCallback(callback);
box.setIcon(MessageBox.WARNING);
box.getDialog().cancelText="someText";
box.setButtons(MessageBox.YESNOCANCEL);
box.show();

Now i just see the Ok button . The buttons yes, no and cancel do not appear anymore.

sven
28 Jul 2010, 1:53 AM
MessageBox box = new MessageBox();
box.setTitle("");
box.setMessage("");
box.addCallback(null);
box.setIcon(MessageBox.WARNING);
box.getDialog().cancelText = "someText";
box.getDialog().setButtons(MessageBox.YESNOCANCEL);
box.show();

hbonpard
28 Jul 2010, 8:02 AM
Great! It works! THX!