02-06-2010 06:08 AM
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.
Solved! Go to Solution.
02-06-2010 02:00 PM - edited 02-06-2010 02:02 PM
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.
02-12-2010 05:58 AM - edited 02-12-2010 06:00 AM
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.
02-12-2010 06:06 AM
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
02-12-2010 06:16 AM
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.
02-12-2010 06:49 AM
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
02-13-2010 10:21 AM
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.