CrazyEngineers
  • Java Programming Help: Following Code Does Not Display Image

    Updated: Oct 26, 2024
    Views: 999
    /*<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?
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • pothedarvamsi

    MemberSep 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.
    Are you sure? This action cannot be undone.
    Cancel
  • rahul69

    MemberSep 4, 2012

    try using '\\' instead of '/' in D:/ backup...
    Are you sure? This action cannot be undone.
    Cancel
  • sulochana anand

    MemberSep 4, 2012

    i tried every way as i can but no result.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register