aspose file tools*
The moose likes Java Micro Edition and the fly likes Png-files doesn't appear in Alert() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Png-files doesn Watch "Png-files doesn New topic
Author

Png-files doesn't appear in Alert()

PV TOKM
Greenhorn

Joined: Aug 04, 2004
Posts: 2
Hi! Excuse me for my worse English.
The problem is: i'm trying to put png-picture in Alert window. Midlet is running correctly in the emulator (picture is on the dipsplay). But when I'm download midlet to the phone (SAMSUNG SGH-X100) by WAP I see only text without picture
In project "Microedition-Proflie" set to "MIDP-1.0"

The code:



public static void showAbout(Display display) {

Alert alert = new Alert("About");
alert.setTimeout(Alert.FOREVER);

if (display.numColors() > 2) {
String icon = (display.isColor()) ?
"/icons/ico.png" : "/icons/ico.png";

try {
Image image = Image.createImage(icon);
alert.setImage(image);
} catch (java.io.IOException x) {
// just don't append the image.
}
}
// Add the copyright
alert.setString(abouttext);

display.setCurrent(alert);
}
Punit Raizada
Ranch Hand

Joined: Mar 20, 2004
Posts: 156
is the image in the JarFile in the specified path ?

can you de-jar it and confirm?? maybe thats the problem.


SCJP 1.4
Everything that can go wrong will go wrong -Murphy
PV TOKM
Greenhorn

Joined: Aug 04, 2004
Posts: 2
I'm only starting to study Java2ME Can you precise you post, please.
May be I'm doing smth wrong?
1. Png-file is stored in ..\apps\MIDLet\res\icons\ico.png.
2. In J2ME - Wireless ToolKit: Project -> Package -> Create package
3. Then I'm uploading MIDlet.jar and MIDlet.jad from ..\apps\MIDLet\bin to my wap-site by HTTP.
4. And then I'm downloading MIDlet.jad by WAP to my phone
Punit Raizada
Ranch Hand

Joined: Mar 20, 2004
Posts: 156
Hi,

Seems like you are adding the Image to your jar in the right way. Can you do a "jar -tf Midlet.jar" on the command prompt to list out the contents of the jar just to be sure.

you should see a listing like "icons/ico.png"

Also can you printout the Exception if any when the you call the Image.createImage(iocn). I would do something like this
try {
Image image = Image.createImage(icon);
alert.setImage(image);
} catch (java.io.IOException x) {
alert.setString(x.getMessage());
}

In MIDP 1.0 the Alert.setImage(Image image) only accepts immutable images. This shouldnt be a issue here as Image.createImage(String s) method that you use to create the Image object returns a immutable image. In my opinion the problem lies
1) Either the Image object is not getting created.
2) or its a Device issue. Check your code on some other device to be sure.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Png-files doesn't appear in Alert()