I am working on a simple applet (as practice, i'm new to java applets), but whenever i load the web page, nothing appears (im pretty sure my html tag is good). there are no errors that are obvious to me, but, as i said i'm new to java applets and there is probably an obvious error. does anyone have an idea as to why its not working? all i'm trying to do is shuffle the deck and then display 10 cards
Code:import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;
import java.net.MalformedURLException;
public class CTYCardsApp extends Applet {
public Image[] cards = new Image[52];
public Boolean[] nums = new Boolean[52];
public void init() {
int i;
for (i = 0; i < 52; i++) {
nums[i] = false;
}
URL docbase = getDocumentBase();
try {
docbase = new URL(getDocumentBase(), "\\images");
} catch (MalformedURLException e) { }
int c = 0;
for(i = 1; i <= 10; i++) {
cards[c] = getImage(docbase, "c" + Integer.toString(i) + ".gif");
c++;
}
for(i = 1; i <= 10; i++) {
cards[c] = getImage(docbase, "s" + Integer.toString(i) + ".gif");
c++;
}
for(i = 1; i <= 10; i++) {
cards[c] = getImage(docbase, "d" + Integer.toString(i) + ".gif");
c++;
}
for(i = 1; i <= 10; i++) {
cards[c] = getImage(docbase, "h" + Integer.toString(i) + ".gif");
c++;
}
cards[40] = getImage(docbase, "cj.gif");
cards[41] = getImage(docbase, "ck.gif");
cards[42] = getImage(docbase, "cq.gif");
cards[43] = getImage(docbase, "dj.gif");
cards[44] = getImage(docbase, "dk.gif");
cards[45] = getImage(docbase, "dq.gif");
cards[46] = getImage(docbase, "hj.gif");
cards[47] = getImage(docbase, "hk.gif");
cards[48] = getImage(docbase, "hq.gif");
cards[49] = getImage(docbase, "sj.gif");
cards[50] = getImage(docbase, "sk.gif");
cards[51] = getImage(docbase, "sq.gif");
shuffle();
}
public void paint(Graphics g) {
int c = 20, i;
for(i = 0; i < 5; i++) {
g.drawImage(cards[i], c, 20, this);
c += 100;
}
c = 20;
for(i = 5; i < 10; i++) {
g.drawImage(cards[i], c, 140, this);
c += 100;
}
}
private void shuffle() {
int i;
Image[] temp = new Image[52];
for(i = 0; i < 52; i++) {
temp[i] = cards[i];
}
for(i = 0; i < 52; i++) {
cards[i] = temp[rand()];
}
}
private int rand() {
int num;
double n;
do {
n = Math.random() * 52.;
num = (int) n;
} while (nums[num]);
nums[num] = true;
return num;
}
}
html code:Code:<html>
<applet code="CTYCardsApp.class" width="500" height="300"/>
</html>

