×
Namespaces

Variants
Actions

Archived:Display.getColor() returns incorrect values in Series 40 2nd Edition (Known Issue)

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.


Article Metadata
Tested with
Devices(s): All
CompatibilityArticle
Created: User:Technical writer 1 (10 Feb 2009)
Last edited: hamishwillee (09 Aug 2013)


Contents

Overview

Display.getColor() returns incorrect values in Series 40 devices.

Description

According to the MIDP specifications, getColor(int colorSpecifier) should return an integer value of one of the colours from the high-level user interface colour scheme, in the form 0x00RRGGBB based on the colorSpecifier passed in.

However, in Series 40 devices, the method returns the colour value in the incorrect form 0xFFRRGGBB.

How to reproduce

The described problem can be reproduced by using the following code:

 import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
 
public class GetColor_Test extends MIDlet implements CommandListener {
 
private static final Command CMD_EXIT = new Command("Exit", Command.EXIT, 1);
private Display display;
 
public GetColor_Test() {
display = Display.getDisplay(this);
}
 
protected void startApp() {
int backgroundColour = display.getColor(Display.COLOR_BACKGROUND);
int foregroundColour = display.getColor(Display.COLOR_FOREGROUND);
int highlightBackgroundColour = display.getColor(Display.COLOR_HIGHLIGHTED_BACKGROUND);
int highlightForegroundColour = display.getColor(Display.COLOR_HIGHLIGHTED_FOREGROUND);
int borderColour = display.getColor(Display.COLOR_BORDER);
int highlightBorderColour = display.getColor(Display.COLOR_HIGHLIGHTED_BORDER);
 
Form mainForm = new Form("GetColor Test");
mainForm.addCommand(CMD_EXIT);
mainForm.setCommandListener(this);
 
mainForm.append("The reported colours should have the format " +
"0x00RRGGBB, where RR, GG and BB are the hex values " +
"for the red, green and blue components of the colour.\n");
 
mainForm.append("Background colour: " + convertToHexString(backgroundColour));
mainForm.append("Foreground colour: " + convertToHexString(foregroundColour));
mainForm.append("Highlight background colour: " + convertToHexString(highlightBackgroundColour));
mainForm.append("Highlight foreground colour: " + convertToHexString(highlightForegroundColour));
mainForm.append("Border colour: " + convertToHexString(borderColour));
mainForm.append("Highlight border colour: " + convertToHexString(highlightBorderColour));
 
display.setCurrent(mainForm);
}
 
protected void pauseApp() {
}
 
protected void destroyApp(boolean arg0) {
}
 
private String convertToHexString(int i) {
String string = Integer.toHexString(i);
string = string.toUpperCase();
while (string.length() < 8) {
string = "0" + string;
}
return "0x" + string + "\n";
}
public void commandAction(Command c, Displayable d) {
if (c == CMD_EXIT) {
destroyApp(false);
notifyDestroyed();
}
}
}

Solution

No solution.

This page was last modified on 9 August 2013, at 07:20.
44 page views in the last 30 days.
×