Picture
On a BlackBerry, the indication panel at the top of the display can be used to display alerts to the user.
Typically this is used to display status changes such as new email messages, new facebook messages or new news feed items etc.
Since OS 4.6, BlackBerrys have had the ability to easily add entries to the notification area.  The image on the left shows a BlackBerry Torch with 2 indicators.

To add an indicator into the notification area, requires that an icon be loaded and stored in the ApplicationIndicatorRegistry and then displayed with an optional numeric value next to it.
To register the indicator icon, use the following code:
EncodedImage indicatorIcon = EncodedImage 
.getEncodedImageResource("indicator.png");
ApplicationIcon applicationIcon = new ApplicationIcon(indicatorIcon);
ApplicationIndicatorRegistry.getInstance().register(applicationIcon,
false, false);
This piece of code loads the image indicator.png from the application and stores it in the ApplicationIndicatorRegistry.  The parameters to the register() method are:
  1. The ApplicationIcon to register
  2. Boolean flag indicating whether to display an icon only or whether to display a numeric value alongside the icon.
  3. Boolean flag indicating whether the application indicator is visible when first created.
Once the icon has been loaded and stored in the registry, it can be updated easily in the notification area:
ApplicationIndicator indicator = ApplicationIndicatorRegistry 
.getInstance().getApplicationIndicator();

indicator.setValue(value);
indicator.setVisible(true);
 
I recently posted on how to programatically set the background color using Java within a BlackBerry app.
This technique works fine if you are using Field Managers to add components on to the screen.
If however, your user interface is drawn within the paint(Graphics g) mehod, this technique does not work. In this case, you need to override the paintBackground(Graphics g) method to set the background color.
protected void paintBackground(Graphics g) {
g.setBackgroundColor(0x000000);
}
 
Setting the background color on a BlackBerry screen is fairly easy. Since JDE 4.6.0, the BackgroundFactory class can be used to accomplish this.
public class MyScreen extends MainScreen { 
public MyScreen() {
// Initialization…
Manager manager = getMainManager();
Background bg =
BackgroundFactory.createSolidBackground(Color.BLACK);
manager.setBackground(bg);
}
}
 
In most programming languages, such as .NET or Java, if you wanted to create a Color object from an RGB, you would execute some method on a Color class passing in Red, Green and Blue values where these values are typically within the range 0 through 255.
If you want to do perform a similar operation in Cocoa, i.e. creating a NSColor object, you need to pass in color values within the range 0 through 1.
Typically, to create a NSColor object in Cocoa, you would use a method such as
[NSColor colorWithDeviceRed: green: blue: alpha:]
To convert RGB values into the appropriate values for this method, you need to add 1 to each separate RGB value and then divide by 256.
So, for example, Alice Blue with an RGB of (240, 248, 255) could be instantiated as a NSColor using the values:
Red: (240+1)/256 = 0.941
Green: (248+1)/256 = 0.973
Blue: (255+1)/256 = 1.0
[NSColor colorWithDeviceRed:0.941 green:0.973 blue:1.0 alpha:1.0] 
 
I’ve spent the last hour or so trying to track down a problem with a multi-threaded GUI Cocoa application that I’ve written.
The problem turned out to be that I was trying to update the applications UI from a background thread. In Cocoa apps, you should only really be updating the applications UI from within the main thread. If you don’t, you get strange results such as the app working in debug and not release or sometimes even hanging altogether.
I fixed the problem by updating the GUI from the background thread by using the performSelectorOnMainThread method. Something similar to below.
-(void)backgroundThread { 
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// .. Update main UI.
[self performSelectorOnMainThread: @selector(updateGui withObject:results waitUntilDone:NO];
// ..
[pool drain];
}
-(void)updateGui:(NSString*) results {
// Update the gui.
}