Results 1 to 2 of 2

Thread: applet

  1. #1
    amith is offline Member
    Join Date
    May 2008
    Posts
    24
    Rep Power
    0

    Default applet

    import java.awt.*;
    import java.applet.*;
    public class a extends Applet
    {
    Image q;
    public void init()
    {

    q=getImage(getCodeBase(),"red.png");
    }
    public void paint(Graphics e)
    {
    e.drawImage(q,200,290,this);
    }
    }
    i hav written this program but it is not showing any red image it is not showing any thing in applet how can i load the icon.png from a folder do i hav to set the class path if so how

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Java Code:
    //  <applet code="LoadAndDraw" width="400" height="400"></applet>
    import java.awt.*;
    import java.applet.*;
    
    public class LoadAndDraw extends Applet
    {
        Image q;
    
        public void init()
        {
            String path = "images/hawk.jpg";
            // Create image object.
            q=getImage(getCodeBase(), path);
            // Load the image data.
            MediaTracker mt = new MediaTracker(this);
            mt.addImage(q, 0);
            try
            {
                mt.waitForID(0);
            }
            catch(InterruptedException e)
            {
                System.out.println(mt.statusAll(false));
            }
        }
    
        public void paint(Graphics e)
        {
            e.drawImage(q, 50, 50, this);
        }
    }

Similar Threads

  1. log4j with Applet
    By sunjavaboy in forum Java Applets
    Replies: 0
    Last Post: 03-25-2008, 12:13 AM
  2. First Applet HELP????
    By nvidia in forum New To Java
    Replies: 0
    Last Post: 08-13-2007, 10:11 PM
  3. Applet Question
    By nvidia in forum Java Applets
    Replies: 1
    Last Post: 08-13-2007, 07:31 PM
  4. Applet
    By kapoorje in forum Java Applets
    Replies: 0
    Last Post: 07-24-2007, 04:06 PM
  5. Replies: 4
    Last Post: 06-08-2007, 06:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •