• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Png-files doesn't appear in Alert()

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is the image in the JarFile in the specified path ?

can you de-jar it and confirm?? maybe thats the problem.
 
PV TOKM
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic