Name: Anonymous 2010-07-30 21:13
hey /prog/ just wondering if anyone could give me a hand with some java code. Basically I am trying to place labels from an array of JLabels into a JPanel using .add, but it doesn't want to work. I have never used an array of JLabels before, so i am certain that i fucked up somewhere.
Code:
public void setProp() {
for (int i = 0; i < label.length; i++) {
label[i] = new JLabel("");
label[i].setPreferredSize(labelDim);
label[i].setIcon(new ImageIcon(this.getClass().getResource("blank.gif")));
label[i].setEnabled(true);
label[i].setVisible(false);
pnlMap.add(label[i]);
}
}
also blank.gif is just a black square and the dimensions are set to match the icon dimensions.
any input would be appreciated
Code:
public void setProp() {
for (int i = 0; i < label.length; i++) {
label[i] = new JLabel("");
label[i].setPreferredSize(labelDim);
label[i].setIcon(new ImageIcon(this.getClass().getResource("blank.gif")));
label[i].setEnabled(true);
label[i].setVisible(false);
pnlMap.add(label[i]);
}
}
also blank.gif is just a black square and the dimensions are set to match the icon dimensions.
any input would be appreciated