import java.awt.*;
import javax.swing.*;
public class Driver
{
public static void main(String[]arg)
{
JFrame frame = new JFrame();
Container cont = frame.getContentPane();
JPanel panel = new JPanel();
JLabel i = new JLabel(new ImageIcon("mail.gif");
No. I am not doing an applet. I have tried Fredrick's code above(thanks!) but result is the same. No error and no image. This puzzles me. I am using Sun One Studio CE. Would it have to do with this problem? Thanks for any help.
myImage = new Image(forgotthis);
panel.add(myImage);
i forgot what type forgotthis was ... but that is how you do it... i can look later, drop me an email at bum0472@hotmail.com and ill tell you exactly what it is.
import java.awt.*;
import javax.swing.*;
public class Driver
{
public static void main(String[]arg)
{
JFrame frame = new JFrame();
Container cont = frame.getContentPane();
JPanel panel = new JPanel();
JLabel i = new JLabel(new ImageIcon("mail.gif");
as you are using Sun One Studio it is probably looking for the image in the root directory of Sun One. Load images relative to a class resource, this will also allow you to put images into a jar file along with your classes.
e.g. ImageIcon icon = new Imageicon( getClass().getResource("images/document.gif" )
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.