Java Reference
In-Depth Information
45.
{
46.
maxHeight = imageHeight;
47.
}
48.
g.drawImage(currentImage,currentXPosition,currentYPosition, this );
49.
currentXPosition += gap + imageWidth;
50.
}// for i
51.
}
52.
53.
public void addImage(String filename)
54.
{
55.
Image im = Toolkit.getDefaultToolkit().getImage(filename);
56.
images.add(im);
57.
repaint();
58.
}
59.
60.
public void addImageAndTrack(String filename)
{
61.
Image im = Toolkit.getDefaultToolkit().getImage(filename);
62.
imageID++;
63.
mediTracker.addImage(im,imageID);
64.
try
65.
{
66.
67.
// Wait for the image to be completely loaded .
68.
mediTracker.waitForID(imageID);
69.
}
70.
catch (InterruptedException ex){
71.
System.out.println("Error loading image "+filename+".");
72.
}
73.
images.add(im);
74.
repaint();
75.
}
76.
77.
public void addImage(Image picture)
78.
{
79.
images.add(picture);
80.
repaint();
}
81.
82.
83.
}
File: its/Images/ImagePanelFrame.java
package its.Images;
1.
2.
3.
import its.SimpleFrame.SimpleFrame;
import java.awt.BorderLayout;
4.
Search WWH ::




Custom Search