如何在Java Swing Applet中显示Image
?
答案 0 :(得分:1)
最简单的方法是将它作为Icon添加到您放在GUI上的JLabel。
http://download.oracle.com/javase/6/docs/api/javax/swing/JLabel.html#JLabel(javax.swing.Icon)
答案 1 :(得分:0)
以下是您需要的概述
class myApplet extends JApplet {
private BufferedImage image;
myApplet() {
try {
image = ImageIO.read(new File("insert image path here"));
} catch (IOException ex) {
// handle exception...
}
}
@Override
public void paint(Graphics g) {
g.drawImage(image, 0, 0, null);
}
}