Friday 21 November 2008

Clear background Colour

I am finding difficulty doing research on finding a clear background colour for my j2me application that is using low level apis.

Currently, I am using these colours:

0xFFFFFF = white
0xBCEE68 = green
0x000000 = black

To set the background colour, use this method
g.setColor(0xFFFFFF);

To set the font colour, use this method
g.setFont((0xFFFFFF);

g in this case refers to Graphics and the bolded part is to specify the colour.
For more information about colours, go to this link: http://www.devx.com/wireless/Article/21452

In the example from this site: http://developers.sun.com/mobility/midp/articles/customitems/index.html

// clear all with background color
g.setColor( DISPLAY.getColor( DISPLAY.COLOR_BACKGROUND ) );
g.fillRect( 0, 0, w, h );

// now use foreground color for drawing
g.setColor( DISPLAY.getColor( DISPLAY.COLOR_FOREGROUND ) );


"We discover the device's default background and foreground colors by calling the Display's getColor() method twice, passing it the appropriate constant each time, COLOR_BACKGROUND, then COLOR_FOREGROUND. Whether we elect to use the default colors or specify our own, OutlineItem.paint() fills a rectangle with the background color, then switches to the foreground color to draw the rest of the content."

No comments: