Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

draw a JPG - easy 1

Status
Not open for further replies.

russland

Programmer
Jan 9, 2003
315
CH
hi,
i'm driving nuts not understanding what it takes to draw a jpg to my tab panel (or any other place in my applet).

this is what i did so far. it fails when i want to instantiate the Graphics object. what am i doing wrong

String firstImage = "C:\\folder\\photos\\test.jpg";
Toolkit tk = Toolkit.getDefaultToolkit();
Image img = tk.getImage(firstImage);
img = getImage(getDocumentBase(), firstImage);
Graphics g = img.getGraphics();


i'd appreciate any help. thanks heaps. (btw. i just read Toolkit class touches OperationSystem dependent resp. native OS behaviours. Any other way to output images in an applet?)
 
1) This forum is for J2EE posts, not core Java API posts. You want the Java (Sun) forum.

2) If you get an error - then post the error. You may not understand fully what it means, but it usually allows experienced programmers to debug a programme more quickly.

3) All Java code relies on OS dependant code. Especially code using native windowing APIs. You'll never get away from that.

4) I was under the impression that AWT related classes could not read JPEGs, only gifs. You'll need to use JAI or the javax.imageio package to decode a JPEG.



--------------------------------------------------
Free Database Connection Pooling Software
 
cheers, fo(u)r these answeres. i'll repost in the accurate forum.
 
your were right. the superclass image is always used... see sun documentation

Class Image java.lang.Object
java.awt.Image
Direct Known Subclasses: BufferedImage, VolatileImagepublic abstract class Imageextends Object The abstract class Image is the superclass of all classes that represent graphical images. The image must be obtained in a platform-specific manner.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top