Java Programming Help: Following Code Does Not Display Image

sulochana anand
@sulochana-anand-OrGmKr โ€ข Oct 26, 2024
/*<applet code="ImageTest.class" width=600 height=500></applet>*/
import java.applet.Applet;
import java.awt.*;
import java.awt.image.*;
public class ImageTest extends Applet
 
{
private Image img;
public void init()
{ img = null; }
public void loadImage() {
try {
img = getImage(getCodeBase(),"D:/backup/mydoc/Picture/picture 002.JPEG");
System.out.println(img);
System.out.println(prepareImage(img, 300, 400, this)); } catch(Exception e){} }
public void paint(Graphics g) {
if (img == null)
{
loadImage();
g.drawImage(img, 10, 10, this);}
else
System.out.print("jj");
}}
 

y this code is unable to show image?

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • pothedarvamsi

    @pothedarvamsi-uhGh3Q • Sep 4, 2012

    Isn't it showing any error?
    if it doesn't then create another new document using notepad(ofcourse we knew that) and rewrite the program then execute it. Sure u'll get the output.

  • rahul69

    @rahul69-97fAOs • Sep 4, 2012

    try using '\\' instead of '/' in D:/ backup...

  • sulochana anand

    @sulochana-anand-OrGmKr • Sep 4, 2012

    i tried every way as i can but no result.