Showing posts with label j2me. Show all posts
Showing posts with label j2me. Show all posts

Thursday, 26 March 2009

StringOptimizer in J2ME

J2ME does not provide the StringOptimizer so you would probably need to create a class of your own. But don't fret! Someone has already done that and you can take it! :D

You could download from here: http://mobilepit.com/09/using-stringtokenizer-in-j2me-javame-applications.html.

=)

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."