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
ronenfe
Posts: 77
Registered: ‎06-03-2009
My Device: Not Specified
Accepted Solution

Alligning fields to center, buttom and autoscrolling.

Hi, I have a few gui questions.

 

1. How can I allign an ActiveRichTextField to the bottom and to the center of the window?

using setstatus works for alligning to bottom, but if user sets the screen font to large font it covers other fields above, and doesn't show beneath them.

2. How do I horizontallty center a BasicEditField?  I read that it uses all width and therefor can't be centered.

3 How do I make the mainwindow scrollable only when fields are getting out of the window, and not scrollable when fields have enough space inside the window? currently it let me scroll even if all fields are shown in the window.

 

I have those problems because I want to support different font sizes and different screen resolutions.

Please use plain text.
Developer
ronenfe
Posts: 77
Registered: ‎06-03-2009
My Device: Not Specified

Re: Alligning fields to center, buttom and autoscrolling.

[ Edited ]

1 and 2 solved using something like that:

 int testWidth = Display.getWidth();
int testString = fieldManagerCopyright.getFont().getAdvance("sample text");
int leftEmptySpace = ( testWidth - testString) / 2;
int testBottom = Display.getHeight();
int bottomEmptySpace = (testBottom - 1);

activeRichTextFieldCopyright.setMargin(0, 0, bottomEmptySpace, leftEmptySpace);
fieldManagerCopyright.add(activeRichTextFieldCopyright);

 

I still need to allign to bottom and number 3.

 

 

Please use plain text.
Developer
ronenfe
Posts: 77
Registered: ‎06-03-2009
My Device: Not Specified

Re: Alligning fields to center, buttom and autoscrolling.

[ Edited ]

since setmargin is not available in 4.7 jde , i used a cusom space field instead using something like that:

 

fieldManagerKey.add(new SpaceField((Display.getWidth() - 
fieldManagerDeviceID.getFont().getAdvance("Device ID "))/2, spaceHeight));

i'm using an horizontal field and adding it the space field before adding it the edit box.

 

 I gave up on alligning to bottom.

 

Please use plain text.
Developer
zany
Posts: 222
Registered: ‎11-11-2009
My Device: Storm

Re: Alligning fields to center, buttom and autoscrolling.

for aligning the field to the center of a row in the screen can be done by setting the field style as FIELD_HCENTER and then add that field to your manager, then the field wil align to the center automatically, also make sure that your manager will fit the whole width of the screen

with regards,
Vignesh J

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Don't forget to mark your post as solved if you get the answer and dont forget to give kudos if the answer is useful for you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please use plain text.
Developer
ronenfe
Posts: 77
Registered: ‎06-03-2009
My Device: Not Specified

Re: Alligning fields to center, buttom and autoscrolling.

Thanks but it won't work with an ActiveRichTextField or a BasicEditField.

I read that by design it takes the whole width and therefor can't be centered.

Please use plain text.
Developer
zany
Posts: 222
Registered: ‎11-11-2009
My Device: Storm

Re: Alligning fields to center, buttom and autoscrolling.

1. How can I allign an ActiveRichTextField to the bottom and to the center of the window?

using setstatus works for alligning to bottom, but if user sets the screen font to large font it covers other fields above, and doesn't show beneath them.

  @ - I am suspecting you have set style as no scroll bars (horizontally and vertically) in your screen. setStatus will always allocate area for your status field at the bottom of your screen and will not give to other managers or component. Status area can be growable, based on your field height. To overcome that, dont set no scroll bars (horizontally and vertically) style to the screen, so that status field will be fixed at the bottom and other components/managers will scroll, if they not able to fit the screen.

 

2. How do I horizontallty center a BasicEditField?  I read that it uses all width and therefor can't be centered.

  @ - yes, native BasicEditField will use full width of the screen. to overcome it, make it as custom field and override getPrefferedWidth() and specify the width what you want give for that field, override layout() like  this

    public void layout (int width, int height)

    {

        super.layout (width, height);

        setExtent (getPreferredWidth(), height);

    }

    and also set the style for this field as FIELD_HCENTER

 

3 How do I make the mainwindow scrollable only when fields are getting out of the window, and not scrollable when fields have enough space inside the window? currently it let me scroll even if all fields are shown in the window.

  @ until you have not set any style for scroll bars (horizontally and vertically) in your screen. it will handled by the screen by default

 

  I think, this will be useful for you

with regards,
Vignesh J

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Don't forget to mark your post as solved if you get the answer and dont forget to give kudos if the answer is useful for you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please use plain text.
Developer
ronenfe
Posts: 77
Registered: ‎06-03-2009
My Device: Not Specified

Re: Alligning fields to center, buttom and autoscrolling.

Thanks, you helped alot, it worked, and i found out I also have to limit the height of the ActiveRichTextField because by default it also uses a height more that the height of the lines i put inside and that is what caused the scolling.

 

 

Please use plain text.