How to put multiple image in java?
ahm, im newbie!
i just got problem about my work...
i just want to make a 4 picture inside a jframe...
[i want to put another 3 pictures inside the frame.]
but im confused i tried anything but it does'nt work...
help me please...
here's the code:
Code:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class ImageApplet extends Applet
{
public static final int IDEAL_WIDTH = 500;
public static final int IDEAL_HEIGHT = 500;
private Image loadImage(String name)
{
Image result = null;
MediaTracker tracker = new MediaTracker(this);
Toolkit toolkit = Toolkit.getDefaultToolkit();
result = toolkit.getImage(name);
tracker.addImage(result, 0);
try
{
tracker.waitForAll();
} catch (InterruptedException e)
{
return null;
}
return result;
}
public void paint(Graphics g)
{
Image see = loadImage("E:\\Miwrath\\pan.jpg");
g.drawImage(see, 0, 0, 200,300,this);
}
public static void main(String args[])
{
Applet applet = new ImageApplet();
Frame frame = new Frame();
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
frame.add(applet);
frame.setSize(IDEAL_WIDTH, IDEAL_HEIGHT);
frame.show();
}
}