| Issue 105: | "java.lang.IllegalArgumentException: This gauge cannot be added to an Alert" unavoidable due to incorrect prefWidth/prefHeight check | |
| 2 people starred this issue and may be notified of changes. | Back to list |
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 https://code.google.com/p/microemu/source/browse/branches/microemulator_2_0_x/microemu-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); } }
Jan 10, 2012
Project Member
#1
bar...@gmail.com
Jan 26, 2012
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.
Jan 31, 2012
Here is the location of snapshot binaries: http://snapshot.microemu.org/microemulator/download/
Jan 31, 2012
Error is fixed in that snapshot version. I still don't see the gauge, but at least it is not throwing any exceptions. |