You Are Here:

Community: Developer Discussion Boards

#1 Old Creating new ImageItem causing java.lang.IllegalArgumentException - 2006-01-24, 21:35

Join Date: Jan 2006
Posts: 5
mkeywood
Offline
Registered User
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.
Reply With Quote

#2 Old Re: Creating new ImageItem causing java.lang.IllegalArgumentException - 2006-01-24, 22:36

Join Date: Aug 2005
Posts: 29
simonhayles
Offline
Registered User
You're not wrong!

Have you tried it on the actual device?
Reply With Quote

#3 Old Re: Creating new ImageItem causing java.lang.IllegalArgumentException - 2006-01-25, 09:42

Join Date: Jan 2006
Posts: 5
mkeywood
Offline
Registered User
No I'm affraid not. I don't have access to one :-(

Anyone any thoughts why this exception is being thrown?

Cheers

Martin.
Reply With Quote

#4 Old Re: Creating new ImageItem causing java.lang.IllegalArgumentException - 2006-01-25, 20:45

Join Date: Aug 2005
Posts: 29
simonhayles
Offline
Registered User
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...
Reply With Quote

#5 Old Re: Creating new ImageItem causing java.lang.IllegalArgumentException - 2006-01-25, 22:49

Join Date: Jun 2005
Posts: 928
dcrocha's Avatar
dcrocha
Offline
Forum Nokia Expert
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
Reply With Quote

#6 Old Re: Creating new ImageItem causing java.lang.IllegalArgumentException - 2006-01-25, 23:04

Join Date: Jan 2006
Posts: 5
mkeywood
Offline
Registered User
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.
Reply With Quote

#7 Old Re: Creating new ImageItem causing java.lang.IllegalArgumentException - 2006-01-25, 23:09

Join Date: Jan 2006
Posts: 5
mkeywood
Offline
Registered User
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.
Reply With Quote

#8 Old Re: Creating new ImageItem causing java.lang.IllegalArgumentException - 2006-01-26, 03:39

Join Date: Jun 2005
Posts: 928
dcrocha's Avatar
dcrocha
Offline
Forum Nokia Expert
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
Reply With Quote

#9 Old Re: Creating new ImageItem causing java.lang.IllegalArgumentException - 2006-01-26, 20:10

Join Date: Jan 2006
Posts: 5
mkeywood
Offline
Registered User
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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
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

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ