mport java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.*;
import java.awt.*;
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JButton;



public class Main extends JApplet implements ActionListener,ItemListener {
	//private Image im;	// image handler
	//private static final String IMAGE = "enviro2.jpg";
	
	//starFish tapakSulaiman = new starFish(this);
	
	public void init() {
   // getImageSimple();
	this.setSize(780,540);
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    
    JPanel input= new JPanel();
    input.setLayout(new GridLayout(1,4));
    
    
    
    ImageIcon fish = new ImageIcon("images/fish.jpg");
    JButton bFish= new JButton("Fish",fish);
    bFish.setLocation(10, 40);
    bFish.setSize(100,100);
    input.add(bFish);
   
    Icon starFish = new ImageIcon("starfish.jpeg");
    JButton bSFish= new JButton("Star Fish",starFish);
   // bFish.setSize(100,100);
    input.add(bSFish);
   
    Icon shell = new ImageIcon("shell.jpeg");
    JButton bShell= new JButton("Shell",shell);
   // bFish.setSize(100,100);
    input.add(bShell);
   
    Icon seaweed = new ImageIcon("seaweed.jpeg");
    JButton bSW= new JButton("Seaweed",seaweed);
   // bFish.setSize(100,100);
    input.add(bSW);
   
   pane.add(input,BorderLayout.SOUTH);
	}
	/*
	private void getImageSimple() {
		// get the image
		im = getImage(getDocumentBase(), IMAGE);
	}
	
	private void getImageWithMediaTracker() {
		// get image
		im = getImage(getDocumentBase(), IMAGE);

		// create and add Media Tracker
		MediaTracker tracker = new MediaTracker(this);
		// add the image to tracker and give it an id say 0
		tracker.addImage(im, 0);
		try {
			// start loading the image with Id = 0
			// in this case the image
			tracker.waitForID(0);
		} catch (InterruptedException e) {
			System.out.println("Error loading Image : " + e.getMessage());
		}
	}
*/
	
	
	
	
	public void actionPerformed(ActionEvent e) {
		 Object obj = e.getSource();
	}
	 public void itemStateChanged(ItemEvent f){
	    	
	    }
}

i do not have idea why the image does appear..by the way, the image is in folder images.

try

ImageIcon fish = new ImageIcon("images\\fish.jpg");

are you sure the image path is correct???
i think one slash '/' requried

two thins i think is the problem is 1.you didn't specify the url of all the image location 2.if the url of the imageicon for fish didn't work out then try using absoulte address e.g c:/images/fish.jpg or gif
ImageIcon fish = new ImageIcon("c:/images/fish.jpg");

two thins i think is the problem is 1.you didn't specify the url of all the image location 2.if the url of the imageicon for fish didn't work out then try using absoulte address e.g c:/images/fish.jpg or gif
ImageIcon fish = new ImageIcon("c:/images/fish.jpg");

ImageIcon fish = new ImageIcon("c:\\images\\fish.jpg");

edit: for Windows OS

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.