ImageIcon.paintIcon wont work in JApplet

Discussion in 'Java' started by Cheok Yan Cheng, Aug 13, 2003.

  1. dear all,
    i try to dispaly d icon within d JApplet but it wont work. the
    following code compiled no problem but nothing had been shown :(

    any suggested solution on this problem?

    thank you.

    regards
    yccheok
    -------------------------------------------------------------------------------

    // LoadImageAndScale.java
    //
    // Load and display the image as an ImageIcon.
    import java.applet.Applet;
    import java.awt.*;
    import javax.swing.*;

    public class LoadImageAndScale extends JApplet
    {
    private ImageIcon logo2;

    // load the image when the applet is loaded
    public void init()
    {
    logo2 = new ImageIcon( getCodeBase()+"logo.gif" );
    repaint();
    }

    // display the image
    public void paint( Graphics g )
    {
    logo2.paintIcon( this, g, 0, 0 );
    }
    }
    Cheok Yan Cheng, Aug 13, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. terry

    JTable ImageIcon

    terry, Aug 5, 2003, in forum: Java
    Replies:
    2
    Views:
    4,055
    Roedy Green
    Aug 6, 2003
  2. Phil...

    How to close ImageIcon file

    Phil..., Oct 9, 2003, in forum: Java
    Replies:
    1
    Views:
    492
    William Brogden
    Oct 9, 2003
  3. David

    SplitPanel and ImageIcon

    David, Oct 16, 2003, in forum: Java
    Replies:
    2
    Views:
    470
  4. Peace
    Replies:
    2
    Views:
    676
    Andrew Thompson
    Sep 29, 2005
  5. Replies:
    3
    Views:
    3,128
    Andrew Thompson
    Aug 12, 2006
Loading...

Share This Page