Important Notes On BlackBerry
The Steps in creation of a Ui
1. Access UiApplication from any where to use invokeLater and other things.
2. Access MainScreen from any where using getScreen() function of a field and UiApplication.
3. Access fields from anywhere using getFieldCount() and getField(int pos)of getScreen() ofand UiApplication, you can use instanceof.UiApplication also gives access on all the previous and next screens.
4. Use invokeLater() of UiApplication to update screen or show alerts in threads.
5. Use Threads to perform the IO Operations. And tiresome processes also.
6. To make custom fields override there onFocus, onUnFocus, layout, paint, paintBackground, drawFocus, isFocusable. To Redraw call the invalidate Function from the outside of the functions using Graphics.
7. For fields like ListField and EditField there are special drawing functions to draw screen as drawListRow, drawText respectively.Don't Override the functions onFocus, onUnFocus, layout, isFocusable for the Multiple Fielded List. You don't even need to override the drawFocus, or paint, or paintBackground as the drawListRow and DrawText are enough. device some conditions to show the focus therein. Issue with the draw Text is that you have to allign the caret position with the Text drawn, hence you have to modify the label of the Field to do so. So you can use the Paint to only draw the other graphics you want, while allow the default drawText to do its drawing.
You need the drawText only if you want to change the color of the text.
Use FocusListener to determine when the internal focus was changed and baased on boolean and the background change the color in the drawListRow. you can get the active focus rect using Graphics g.getClipRect(); that returns XYRect.
8. Context Menu are specific to Fields and MenuItem are specific to Screens.
9. Search: return original when search string null, return null when search result null, return the results.
Vectors can be very helpful.
10. Access and Set the System Font from any where, specify size between 10 and 20 from Font, FontFamily class.
11. The height of every field in a vertical arrangement is Display.getHeight()/6. so that 6 fields can be placed one on the top of other to fill up the screen.
12. On Screen subLayout fixes left, top origin of display; setExtent fixes width, height.
13. For fields : to position the fields on the Screen call childLayout, which will set the height and width of the field and call the setPosition child to set the x,y of the left top of the field.
14. If you call getContentRect of the field you get the rect where the content is occupied, while the getExtent gives you the whole rect occupied by the field.
15. Make two Managers : 1 for painting and another for laying out the buttons on the screen. add painted manager in the manager with fields and then add fields in the. The default mainscreen which has these managers should be laid out properly.
OTA deployment of the COD files.
1. The Application (Ui) has to be made in a way that it consists of Main UiApplication and other classes in the form of library. This should insure that each part is less than 60KB. compile packages in the Application into a different lirary (without the Application).
2. The OTA now will not modify the library jars and treat them as the essential part of the main Application.
1. After the signing, Extract the cod file using a ZIP utility if it is too big.
2. modify the names with a common suffix and the same in the JAD file with the size before deploying.
1) make singleton classes.
2) use public inner classes (instead of making new instances) in just one class. You can pass the address of the classes declared as public in main class to the requiring functions or classses. Save resources.
3) Use synchronize (blocks or access type)only if you see there are objects shared by multiple threads and a semaphore is needed.
4) In threads the global variables can't be used, try use final variables.
5) don't use too much of / unnecessary static variables.