There are various UI techniques the developers need to follow and various concerns need to concentrate on. The major among all is device resolution. As we all know, in blackberry market the mass of the JDE versions are still 4.5. When we target an application for blackberry smartphone we cant leave JDE4.5 version devices.
Basically if we consider the devices like pearl we have less screen width as compared to other models like torch, storm or curve.Consider a business application where we have a choice field or a label field which need to fit in multiple screen resolution device. How smart are you to handle this?.Here we need to take font into consideration and few set of logic need to change in you customized choice field. The font need to calculate dynamically as per the screen with. Here is a code snapshot which will guide you to customize this for objectChoiceField.
protected void paint(Graphics graphics) { Resolutions r = new Resolutions(); Font labelFont = r.getFont(); Font font = r.getFont(); int width = r.CustomRowWidth - 3; int calcWidth = 0; while(width<(font.getAdvance(label)+maxWidth(font))){ calcWidth = labelFont.getAdvance(label)+maxWidth(font); int height = font.getHeight(); height = height - 2; FontFamily fontFamily = null; fontFamily = Font.getDefault().getFontFamily(); font = fontFamily.getFont(Font.PLAIN,height); } graphics.setFont(font); this.setFont(font); if (-1 != mFontColor) graphics.setColor(mFontColor); super.paint(graphics); }
Here maxWith() method calculates the maximum length among all the choices available in choiceField.
public int maxWidth(Font font){ int max = -1; for(int i =0;i<this.getSize();i++){ String s = (String)this.getChoice(i); int width =font.getAdvance(s); if(width>max) max = width; } return max; }