L'immagine si posizione al centro (...) della finestra grafica
Codice Html
<applet code="a_duke_0.class" width="360" height="240">...</applet>
Codice Html
<applet code="a_duke_0.class" width="480" height="360">...</applet>
Codice Java
import java.applet.*;
import java.awt.*;
public class a_duke_0 extends Applet
{
private Image immagine;
public void init()
{
immagine=getImage(getCodeBase(), "duke.jpg");
}
public void paint(Graphics g)
{
// centro dell'applet...
int x=getSize().width/2;
int y=getSize().height/2;
g.drawImage(immagine, x, y, this);
}
} |