| Reply | « Previous Thread | Next Thread » |
|
I am using the the Nokia Developer's Suite using a Series 60 Emulator and a 7210 Emulator for basic Series 40 tests.
This problem is ONLY occuring on the 7210 Emulator. When creating a new ImageItem with it crashing with java.lang.IllegalArgumentException. I have narrowed it down and can be reproduced in the small piece of code below. Basically, no matter how I create the Image that is passed into ImageItem (either loading an image or creating a blank image (and optionally putting text or whatever on it)) or whatever other parameters I use it crashes. If I pass in image as null it doesn't crash, but then if I try and call setImage() on it with a more sensible image it crashes with java.lang.IllegalArgumentException then :-( I read in the MIDP2 that there is a 5 parameter ImageItem constructor since MIDP2.0 put I am not using that. I am using the simpler 4 parameter call which I believe to be present since MIDP1.0. Please can some advise where I am going wrong. Thanks in advance Martin. -=-=-=-=-=-=-=-=-=- import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class test extends MIDlet { private Display display; private Graphics g; private Form myForm; private ImageItem myImageItem; private Image myImage; public test() { display = Display.getDisplay(this); myForm = new Form(null); myImage = Image.createImage(128, 128); g = myImage.getGraphics(); g.drawString("Hello", 50, 50, Graphics.HCENTER | Graphics.BASELINE); // Errors Here, hence the try{} catch{} to output the exception :-( try { myImageItem = new ImageItem(null, myImage, ImageItem.LAYOUT_CENTER, null); } catch (Exception e) { System.err.println(e.toString()); } myForm.append(myImageItem); display.setCurrent(myForm); } public void startApp() { } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void close() { destroyApp(true); notifyDestroyed(); } }
Last edited by mkeywood : 2006-01-24 at 21:40.
|
|
You're not wrong!
Have you tried it on the actual device? |
| simonhayles |
| View Public Profile |
| Find all posts by simonhayles |
|
No I'm affraid not. I don't have access to one :-(
Anyone any thoughts why this exception is being thrown? Cheers Martin. |
|
Tried it on the handset - Same error. Must be a bug in the 7210 firmware.
You'll have to find another way to do your app, maybe using a canvas rather than a form? Another one for the 'Wierd Nokia Bug' database... |
| simonhayles |
| View Public Profile |
| Find all posts by simonhayles |
|
Hello,
No bugs here. The specification for the ImageItem constructor is clear: public ImageItem(String label, Image img, int layout, String altText)Creates a new ImageItem with the given label, image, layout directive, and alternate text string. Parameters: label - the label string img - the image, must be immutable layout - a combination of layout directives altText - the text that may be used in place of the image Throws: IllegalArgumentException - if the image is mutable IllegalArgumentException - if the layout value is not a legal combination of directives You cannot use a mutable image in ImageItem's constructor. Daniel |
|
Thanks for the replies.
I forgot to mention that when I was trying various combinations to get it working I tried loading an image by specifying a valid filename in createImage instead of specifying a width/height, which therefore would have been immutable, but that gave me the same error when constucting the ImageItem. I am trying the same code on the Nokia Prototype SDK Series 40's and it's fine. It's just that 7210. BTW, where did you get that description of ImageItem from because the one I am using, from Sun's WTK, only states that error in relation to an invalid layout and doesn't go into the details of the one you cut/pasted. Thanks alot Martin. |
|
Actually, looking at Suns WTK MIDP spec again it says:
ImageItem public ImageItem(String label, Image img, int layout, String altText)Creates a new ImageItem with the given label, image, layout directive, and alternate text string. Parameters: label - the label string img - the image, can be mutable or immutable layout - a combination of layout directives altText - the text that may be used in place of the image Throws: IllegalArgumentException - if the layout value is not a legal combination of directives so now I'm really confused as it thinks it should be fine, but contradicts the info pasted to this thread earlier. It als says it has been in since MIDP 1.0 so should be fine. Any thoughts? Cheers Martin. |
|
Hello,
This constructor which takes a mutable or immutable is valid only for MIDP 2.0. To have access to the actual MIDP 1.0 javadocs, please take a look at C:\Nokia\Devices\Nokia_7210_MIDP_SDK_v1_0\docs\api\index.html. As far as I know, Prototype SDK implements MIDP 2.0, doesn't it? The "Since MIDP 1.0" tag means that the ImageItem class was there since 1.0, but the behavior can be different. Anyway, if you have tried an immutable image and it still does not work, then we can have an issue. Can you post the code you used, with an immutable image? Daniel |
|
Well I stand corrected. I'm sure I tried an immutable image :-(
The problem is, as you describe, with the mutability of that image. Thanks to all who have helped me understand this. Back to the old drawing board :-) Martin. |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| problem while creating database | ManishPatil | General Symbian C++ | 4 | 2003-12-26 16:33 |
| abld make files missing | dalore | General Symbian C++ | 0 | 2003-06-13 13:40 |
| IOException upon creating Application Package | zikko | Mobile Java Tools & SDKs | 3 | 2003-06-02 12:51 |
| abld command | kollar | Symbian Tools & SDKs | 3 | 2003-02-03 08:51 |
| Problem with bldmake bldfiles for Series 60 SDK 6.1 | dml | Symbian Tools & SDKs | 3 | 1970-01-01 02:00 |