Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Icons in Java1.1.8

Status
Not open for further replies.

JSamadi

Programmer
Jan 28, 2001
7
CA
Hi,

Another message so soon!

I am trying to do some dialog boxes and other screens that require an image. The only examples I've been able to find about images in Java, are using Swing or using applets and image URLs.

I am restricted to using 1.1.8 AWT. Does anyone have advice on loading images, or better yet, a tutorial link.

I've seen the createImage, drawImage and ImageObserver/Producer stuff. It's just a bit confusing still.

Thanks
 
Hi!

Here is a very-very simple image loader snippet (from applet):

static Image[] imgLeds;
final private void loadImages() {
int i, j;
MediaTracker mt;

showStatus("Loading images...");
imgLeds=new Image[2];
imgLeds[0]=getImage(getCodeBase(), "LedOff.gif");
imgLeds[1]=getImage(getCodeBase(), "LedOn.gif");


mt=new MediaTracker(this);
mt.addImage(imgLeds[0], 0);
mt.addImage(imgLeds[1], 1);
try { mt.waitForAll(); }
catch (Exception e) { System.out.println("Image load error: "+e); }
showStatus("");
}

Good luck. Bye, Otto.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top