Nå men nu har jeg sat det ind, og jeg kan fint compile, men jeg kan stadig ikke få den frem i browseren...men jeg kan fint med appletviewer... Det er sgu da sært synes jeg
public class header extends JApplet { //private ImageIcon icon = new ImageIcon("line.jpg"); ImageIcon icon = new ImageIcon(this.getClass().getResource("line.jpg")); private Image line = icon.getImage(); private Graphics g; public void init() { setBackground(Color.white); setForeground(Color.white);
}
public void paint(Graphics g) { //ImageIcon i = new ImageIcon("background.jpg"); ImageIcon i = new ImageIcon(this.getClass().getResource("background.jpg")); Image j = i.getImage(); g.drawImage(j,0,0,this); this.g = g; animationFromLeft("saa",241,93); animationFromLeft("Godt",120,111); int temp = 0; for (int h=1; h<=3; h++) { temp= temp+22; animationFromRight("dot",334+temp,12); } try{Thread.sleep(1700);} catch (InterruptedException e) {} animationFromRight("eller",420,122); }
public void animationFromLeft(String imageName, int x, int imageWidth) { ImageIcon i = new ImageIcon(this.getClass().getResource(imageName+".jpg")); //ImageIcon i = new ImageIcon(imageName+".jpg"); Image j = i.getImage(); for (int v=0; v<=x+10; v++) { g.drawImage(j,v,0,this); g.drawImage(line,v-1,0,this); try{Thread.sleep(6);} catch (InterruptedException e) {}
} for (int k=x+10; k>=x; k=k-1) { g.drawImage(j,k,0,this); g.drawImage(line,k+imageWidth+1,0,this); try{Thread.sleep(8);} catch (InterruptedException e) {} } } public void animationFromRight(String imageName, int x, int imageWidth) { ImageIcon i = new ImageIcon(this.getClass().getResource(imageName+".jpg")); //ImageIcon i = new ImageIcon(imageName+".jpg"); Image j = i.getImage(); for (int v=650; v>=x; v=v-2) { g.drawImage(j,v,0,this); g.drawImage(line,v+imageWidth,0,this); g.drawImage(line,v+imageWidth+1,0,this); try{Thread.sleep(5);} catch (InterruptedException e) {} } }
hmm jeg kan sagtens køre de images, men får nullpointerexception på dine threads... Sig mig hvorfor prøver du ikke at lave den animation som jeg viste dig i din sidste tråd?
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.