Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

"java.lang.IllegalArgumentException: This gauge cannot be added to an Alert" unavoidable due to incorrect prefWidth/prefHeight check #105

Open
GoogleCodeExporter opened this issue Mar 13, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Create a MidLet that adds a Gauge to an Alert and shows it (see below)
2. Test it in Oracle's emulator or real device to make sure it works
3. Test it in MicroEmulator

What is the expected output? What do you see instead?

It should work. Instead it creates this exception:

java.lang.IllegalArgumentException: This gauge cannot be added to an Alert
    at javax.microedition.lcdui.Alert.setIndicator(Alert.java:184)
    at microemu.GaugeAlert.startApp(GaugeAlert.java:17)
    at javax.microedition.midlet.MIDlet$MIDletAccessor.startApp(MIDlet.java:49)
    at org.microemu.app.Common.startMidlet(Common.java:428)

When attaching to it with a debugger, it shows that prefHeight and prefWidth 
are defined twice, once private in Item and once (shadowed) package private in 
Gauge. The variables of Gauge are both 0, and the code checks them for being -1 
(see 
http://code.google.com/p/microemu/source/browse/branches/microemulator_2_0_x/mic
roemu-midp/src/main/java/javax/microedition/lcdui/Alert.java#176). Setting them 
-1 in the debugger makes the alert visible. I could not find any code that 
tries to set these shadowed variables, so I assume it was a mistake to have 
these variables there at all.

What version of the product are you using? On what operating system?

2.0.4 on Windows XP

Please provide any additional information below.

package microemu;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class GaugeAlert extends MIDlet {

    protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
    }

    protected void pauseApp() {
    }

    protected void startApp() throws MIDletStateChangeException {
        Alert a = new Alert("Hello Gauge");
        a.setTimeout(Alert.FOREVER);
        a.setIndicator(new Gauge(null, false, 5, 2));
        Display.getDisplay(this).setCurrent(a);
    }
}


Original issue reported on code.google.com by schie...@gmail.com on 21 Dec 2011 at 8:03

@GoogleCodeExporter
Copy link
Author

Can you try the 3.0.0-SNAPSHOT version?

Original comment by bar...@gmail.com on 10 Jan 2012 at 8:14

@GoogleCodeExporter
Copy link
Author

Are there any (sufficiently new) snapshot binaries available or does that mean 
I have to get the source from SVN and (try to) build it myself? If the latter, 
it can take a while until I find time for doing that.

Original comment by schie...@gmail.com on 26 Jan 2012 at 6:03

@GoogleCodeExporter
Copy link
Author

Here is the location of snapshot binaries:
http://snapshot.microemu.org/microemulator/download/

Original comment by bar...@gmail.com on 31 Jan 2012 at 11:01

@GoogleCodeExporter
Copy link
Author

Error is fixed in that snapshot version. I still don't see the gauge, but at 
least it is not throwing any exceptions.

Original comment by schie...@gmail.com on 31 Jan 2012 at 5:34

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant