ImageIcon.paintIcon wont work in JApplet

C

Cheok Yan Cheng

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 );
}
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top