This week's book giveaway is in the Cloud forum.
We're giving away four copies of The Business Blockchain and have William Mougayar on-line!
See this thread for details.
Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Graphics in J2Me

 
Reeti Saha
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to draw some lines and wants to show some images also using J2ME toolkit. How to achieve this? I'm able to draw lines but cldn't draw thick lines yet. How to display small .png files?
Pls. help.
Thanks and Regards
Reeti
 
Eric Giguere
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to draw thick lines yourself, i.e. draw several lines close together. As for images, you call Image.createImage to get the image and then drawImage on the Graphics object to draw it.
Eric
------------------
Eric Giguere
author of:
Java 2 Micro Edition : A Professional Developer's Guide
PalmTM Database Programming: The Complete Developer's Guide
 
Reeti Saha
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the help.
As I'm very new in this area, I'm bit confused as how to proceed. Suppose I've xx.png file in my c drive then how do I display the image using J2ME.
Pls. help.
Regds
Reeti
 
Eric Giguere
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say "J2ME", do you mean MIDP? PersonalJava? Or the CLDC reference implementation? J2ME means a lot of things, and you have to be specific.
For MIDP, the PNG file must be packaged into the MIDlet suite's JAR file. That's the only way to access it short of downloading it as a binary using HTTP. You then do this:
Image img = null;
try {
img = Image.createImage( "/images/foo.png" );
}
catch( IOException e ){
}
This assumes that the PNG file is stored as /images/foo.png in the JAR file, of course.

------------------
Eric Giguere
author of:
Java 2 Micro Edition : A Professional Developer's Guide
PalmTM Database Programming: The Complete Developer's Guide
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic