How to display image using Applet?
SolutionFollowing example demonstrates how to display image using getImage() method. It also uses addImage() method of MediaTracker class.
import java.applet.*; import java.awt.*; public class appletImage extends Applet { Image img; MediaTracker tr; public void paint(Graphics g) { tr = new MediaTracker(this); img = getImage(getCodeBase(), "demoimg.gif"); tr.addImage(img,0); g.drawImage(img, 0, 0, this); } }Result
The above code sample will produce the following result in a java enabled web browser.
View in Browser.
java_applets.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4