You Are Here:

Community: Developer Discussion Boards

#1 Old How to load an image in my application - 2007-04-15, 10:15

Join Date: Apr 2007
Posts: 7
golam.kaosar
Offline
Registered User
Dear all,
I know how to program in java. but dont have much idea about J2ME. i want a quick start thats why before going through detail, i want to develop a small application which would load an image (jpg or png) on the screen. i have been trying several times and looked at several forum posts here, but unfortunately i could not b succeed yet. would you please help me providing a small piece of code and step by step instructions!!!! please please please!!!
u can send email to me too (golam.kaosar@gmail.com)

thanks a lot.
Reply With Quote

#2 Old Re: How to load an image in my application - 2007-04-15, 11:00

Join Date: Dec 2006
Posts: 86
Location: Mumbai
pvumesh's Avatar
pvumesh
Offline
Registered User
Hi golam.kaosar,

check the javax.microedition.lcdui.Image class.
this is javadoc for it....

http://www.j2medev.com/api/midp/java...use/Image.html

this is the way you put an image into your midlet

Image b;
b.createImage("image.png");


With Regards,
Mitesh Manani
http://getpass.netfirms.com
Reply With Quote

#3 Old Re: How to load an image in my application - 2007-04-15, 12:29

Join Date: Apr 2007
Posts: 7
golam.kaosar
Offline
Registered User
dear,
thanks a lot for quick reply. i already saw these classes. but i tried in several ways and did not get success. now i m confused about the whole process. therefore an example program (code) would be the best remedy for this problem. if u have such example, please let me know.
thanks again.
Reply With Quote

#4 Old Re: How to load an image in my application - 2007-04-15, 19:01

Join Date: Dec 2006
Posts: 86
Location: Mumbai
pvumesh's Avatar
pvumesh
Offline
Registered User
copy paste your part of the code so that i can make out the mistake that your making. try to do it yourself rather than getting the readymade code...
You will learn better.


With Regards,
Mitesh Manani
http://getpass.netfirms.com
Reply With Quote

#5 Old Re: How to load an image in my application - 2007-04-16, 07:27

Join Date: Apr 2007
Posts: 7
golam.kaosar
Offline
Registered User
here is the code:
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import java.io.*;
public class ImageTest extends Canvas implements Runnable{
private Image image;
private int x;
private int y;
private TiledLayer layer;
public ImageTest(String imageName)
throws ApplicationException {
try{
image=Image.createImage("/image1.png");
layer=new TiledLayer(7,7,image,20,20);
x=(getWidth()-layer.getHeight())/2;
y=(getHeight()-layer.getWidth())/2;
layer.setPosition(x,y);
}catch (IOException e){
throw new Exception("Unable to create Image");
}
}
public void paint(Graphics g){
layer.paint(g);
}
public void run(){
int n=0;
while(n<=21){
for(int i=0;i<7;i++){
for(int j=0;j<7;j++){
layer.setCell(i,j,(i+1)+n+(j*28));
}
}
repaint();
try{
Thread.sleep(100);
}catch(InterruptedException ie){}
n++;
}
}
}

here the constructor has an argument. i dont know when and how the argument should be sent. also i dont know where the image file should be located. if i run this program following error occurs:
Project "ImageTest" loaded
Project settings saved
Building "ImageTest"
C:\java\WTK\apps\ImageTest\src\ImageTest.java:10: cannot find symbol
symbol : class ApplicationException
location: class ImageTest
throws ApplicationException {
^
1 error
com.sun.kvem.ktools.ExecutionException
Build failed

i am using java wireless toolkit
i really appreciate and thank you for your kind and prompt reply.
Reply With Quote

#6 Old Re: How to load an image in my application - 2007-04-16, 12:47

Join Date: Dec 2004
Posts: 184
shaii
Offline
Regular Contributor
your error isnt related to loading an image nor even to j2me
if u know java then it should be easy for u
it says it cant find the class ApplicationException
u declare the constructor to throw "ApplicationException" which is not a class or not in the src folder or the class-path
i think u ment "throws Exception"
since later on u do throw an Exception and nothing else


p.s
STOP SPAMMING your problem on all open threads
thread jacking is not nice or will help u
open one thread and wait for assistance
Reply With Quote

#7 Old Re: How to load an image in my application - 2007-04-16, 13:22

Join Date: Apr 2007
Posts: 7
golam.kaosar
Offline
Registered User
can u please give me a piece of code which would load an image file as the background of the application?
thanks
Reply With Quote

#8 Old Re: How to load an image in my application - 2007-04-16, 21:40

Join Date: Dec 2006
Posts: 86
Location: Mumbai
pvumesh's Avatar
pvumesh
Offline
Registered User
make sure all the images are in the res folder of your toolkit.


With Regards,
Mitesh Manani
http://getpass.netfirms.com
Reply With Quote

#9 Old Re: How to load an image in my application - 2007-04-17, 07:47

Join Date: Apr 2007
Posts: 7
golam.kaosar
Offline
Registered User
yes the image is there. i tried with the full path name too. i appreciate ur help. can i get your email address so that we could have more prompt communication.
thanks a lot
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
load multiple images using 1 CFbsBitmap variable result in same image Rx-lee General Symbian C++ 1 2006-11-15 08:03
Load image from MBM file palak_shah_23 Symbian User Interface 17 2006-11-04 14:36
How to load application in N80? shiloliu Mobile Java Networking & Messaging & Security 1 2006-08-09 12:19
Can I install my application software into an image phone? huangtx2004 General Discussion 3 2004-08-23 05:41
Nokia Image Converter davidpurdie General Discussion 0 2004-02-18 16:31

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: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X 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