home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magazyn WWW 2000 June
/
www-06-2000.iso
/
java
/
Main.java
< prev
next >
Wrap
Text File
|
2000-04-11
|
856b
|
36 lines
import java.awt.*;
import java.io.*;
public class Main extends Component {
private Image image;
public Main() {
setBackground(Color.yellow);
}
public void paint(Graphics g) {
if (image==null) {
ByteArrayOutputStream bytes=new ByteArrayOutputStream();
byte[] buffer=new byte[1024];
int count;
InputStream is=getClass().getResourceAsStream("Anim.gif");
try {
do {
count=is.read(buffer);
if (count>0) {
bytes.write(buffer, 0, count);
}
} while (count>=0);
} catch (IOException ex) {
ex.printStackTrace();
} finally {
try { is.close(); } catch (IOException ex) {}
}
image=getToolkit().createImage(bytes.toByteArray());
try { bytes.close(); } catch (IOException ex) {}
}
g.drawImage(image, 0, 0, getSize().width, getSize().height, this);
}
}