Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

dialog box buttons to be displayed in Horizontal manner

Hi I have created a Dialog Box but my Buttons are displayed in vertical manager one below other But i need them in Horizontal Manner...I have customised it by extending the Dialog class i am pasting the code below kindly help...

 

import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; import net.rim.device.api.system.*; public class TestDial extends Dialog { public TestDial(String choices[],int values[],String comments) { super(comments, choices,values,Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.QUESTION), Dialog.GLOBAL_STATUS); } public void paint(Graphics graphics) { graphics.setBackgroundColor(Color.DIMGRAY); graphics.clear(); super.paint(graphics); } }

when i need a dialog i call it as below shown....

 

 

 

TestDial dial1; String choices[] = {"Save All","CANCEL Exit"}; int values[] = {Dialog.OK,Dialog.CANCEL}; String comments = "Click Saave All to save and Cancel to Exit"; dial1 = new TestDialog(choices,values,comments);

My probem is the buttons on the dialog box are displayed vertical one below the other i want them to display in horizontal manner.

Developer
Posts: 455
Registered: ‎01-14-2009
My Device: Apple iPhone 3GS 16GB

Re: dialog box buttons to be displayed in Horizontal manner

Instead of providing the arguments to super() create a   HorizontalFieldManager hfm1 = new HorizontalFieldManager();


and then add the buttons to the   HorizontalFieldManager.. and then add the  HorizontalFieldManager to the screen                        

Developer
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

Re: dialog box buttons to be displayed in Horizontal manner

I dint get you...can u explain with the code.....
Developer
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

Re: dialog box buttons to be displayed in Horizontal manner

Can anyone pls help regarding my problem for displaying the Buttons Dialog Box Horizontally next to each other...
Developer
Posts: 455
Registered: ‎01-14-2009
My Device: Apple iPhone 3GS 16GB

Re: dialog box buttons to be displayed in Horizontal manner

Create a custom dialog. with three buttons, and then add those buttons to Horizontal Field Manager.
Developer
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

Re: dialog box buttons to be displayed in Horizontal manner

above u can fine i have customised the Dialog class how to add into it....kindly guide...
Developer
Posts: 455
Registered: ‎01-14-2009
My Device: Apple iPhone 3GS 16GB

Re: dialog box buttons to be displayed in Horizontal manner

import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; import net.rim.device.api.system.*; public class TestDial extends Dialog { public TestDial(String choices[],int values[],String comments) { super(comments, choices,values,Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.QUESTION), Dialog.GLOBAL_STATUS); //add buttons here. eg: cancelButton=new ButtonField("Cancel",ButtonField.FIELD_RIGHT|ButtonField.CONSUME_CLICK); HorizontalFieldManager hfm1 = new HorizontalFieldManager(); hfm1.add(cancelButton); add(hfm1); } public void paint(Graphics graphics) { graphics.setBackgroundColor(Color.DIMGRAY); graphics.clear(); super.paint(graphics); } }

 

Developer
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

Re: dialog box buttons to be displayed in Horizontal manner

ok thank u
Highlighted
New Contributor
Posts: 3
Registered: ‎06-30-2012
My Device: BlackBerry 9860
My Carrier: MTS

Re: dialog box buttons to be displayed in Horizontal manner

It is not the correct solution. I mean that this code provides you with 3 buttons; first is in horizontal manager, other 2 - in vertical.