Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java array help

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

Name: Anonymous 2010-07-31 0:00

>>13
>>14
>>16
Know what guys? this is the first time I have ever tried something like this, and all I have ever done was retarded input/output school work that was not complex at all (which i am sure this isnt either but i am retarded).

I have never been to /prog/ before (as i am sure you all have noticed), so maybe toss me a rope.

as far as code goes, that method is basically it. I have a button that calls the method, and said button and panel were made by dragging them onto my frame in netbeans.

and i know this is a long enough explanation, but i just want a push in the right direction so i can hopefully get this figured out.

tl;dr: im retarded, just looking for some help

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List