×
Namespaces

Variants
Actions
Revision as of 11:37, 14 August 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Java ME Gauge progress bar disappears on S60 3rd Edition FP1 (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}}.

This known issue was originally created by Cyberal and has been verified by Nokia Developer.

Article Metadata
Tested with
Devices(s): Nokia N95 8GB, Emulator
CompatibilityArticle
Created: cyberal_ (02 Oct 2008)
Last edited: hamishwillee (14 Aug 2013)

Contents

Overview

The javax.microedition.lcdui.Gauge progress bar disappears from the form. The label and the space occupied by the progress bar remain on the screen.

Description

When instantiating a new non-interactive Gauge indicating an INDEFINITE maximum value (and possibly a CONTINUOUS_RUNNING value) and changing the Maximum value to make it a DEFINITE gauge, the progress bar disappears. However, if the gauge is instantiated as a DEFINITE value (that is, Max = 100, Val = 50) and changed to INDEFINITE and back, it works.

The same code works on the Sun Java Wireless Toolkit 2.5.2 platform emulator.

How to reproduce

 import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
 
public class GaugeProblem extends MIDlet implements CommandListener {
 
Form form = new Form("GaugeProblem");
Gauge gauge = new Gauge("Indefinite", false, Gauge.INDEFINITE,
Gauge.CONTINUOUS_RUNNING);
Command exitCommand = new Command("Exit", Command.EXIT, 1);
Command changeCommand = new Command("Change", Command.SCREEN, 2);
 
public GaugeProblem() {
form.append(gauge);
form.addCommand(exitCommand);
form.addCommand(changeCommand);
form.setCommandListener(this);
}
 
void init() {
Display.getDisplay(this).setCurrent(form);
}
 
void changeGauge() {
if (gauge.getMaxValue() == Gauge.INDEFINITE) {
gauge.setLabel("Definite");
gauge.setMaxValue(100);
gauge.setValue(50);
} else {
gauge.setLabel("Indefinite");
gauge.setMaxValue(Gauge.INDEFINITE);
gauge.setValue(Gauge.CONTINUOUS_RUNNING);
}
}
 
void exitMIDlet() {
try {
destroyApp(true);
} catch (MIDletStateChangeException ex) {
ex.printStackTrace();
}
notifyDestroyed();
}
 
protected void startApp() throws MIDletStateChangeException {
init();
}
 
protected void pauseApp() {
}
 
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
 
public void commandAction(Command command, Displayable arg1) {
if (command == exitCommand) {
exitMIDlet();
} else if (command == changeCommand) {
changeGauge();
}
}
}


Solution

A workaround to this issue is to instantiate the Gauge with a definite value, and immediately after creation/appending to form, change it to INDEFINITE, and then back to definite as needed.

 import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
 
public class GaugeProblem extends MIDlet implements CommandListener {
 
Form form = new Form("GaugeProblem");
Gauge gauge = new Gauge("Indefinite", false,
100, //Gauge.INDEFINITE,
50); //Gauge.CONTINUOUS_RUNNING);
 
Command exitCommand = new Command("Exit", Command.EXIT, 1);
Command changeCommand = new Command("Change", Command.SCREEN, 2);
 
public GaugeProblem() {
// PATCH TO SOLVE DISAPPEARING GAUGE
gauge.setMaxValue(Gauge.INDEFINITE);
gauge.setValue(Gauge.CONTINUOUS_RUNNING);
// END OF PATCH
form.append(gauge);
form.addCommand(exitCommand);
form.addCommand(changeCommand);
form.setCommandListener(this);
}
 
void init() {
Display.getDisplay(this).setCurrent(form);
}
 
void changeGauge() {
if (gauge.getMaxValue() == Gauge.INDEFINITE) {
gauge.setLabel("Definite");
gauge.setMaxValue(100);
gauge.setValue(50);
} else {
gauge.setLabel("Indefinite");
gauge.setMaxValue(Gauge.INDEFINITE);
gauge.setValue(Gauge.CONTINUOUS_RUNNING);
}
}
 
void exitMIDlet() {
try {
destroyApp(true);
} catch (MIDletStateChangeException ex) {
ex.printStackTrace();
}
notifyDestroyed();
}
 
protected void startApp() throws MIDletStateChangeException {
init();
}
 
protected void pauseApp() {
}
 
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
 
public void commandAction(Command command, Displayable arg1) {
if (command == exitCommand) {
exitMIDlet();
} else if (command == changeCommand) {
changeGauge();
}
}
}
This page was last modified on 14 August 2013, at 11:37.
42 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×