Hi all, first post here

My question is, why does this work as expected:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| public class AppTest extends Applet { Image i; public void init() { } public void paint(Graphics g) { i = createImage(this.getWidth(), this.getHeight()); Graphics b = i.getGraphics(); try { b.drawImage(this.getImage(new URL(this.getCodeBase(), "dude.png")), 0, 0, null); } catch (MalformedURLException e) { e.printStackTrace(); } b.dispose(); g.drawImage(i, 0, 0, null); repaint(); } } |
But this doesn't draw anything:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| public class AppTest extends Applet { Image i; public void init() { i = createImage(this.getWidth(), this.getHeight()); Graphics b = i.getGraphics(); try { b.drawImage(this.getImage(new URL(this.getCodeBase(), "dude.png")), 0, 0, null); } catch (MalformedURLException e) { e.printStackTrace(); } b.dispose(); } public void paint(Graphics g) { g.drawImage(i, 0, 0, null); repaint(); } } |