hello everyone
i need to create DYNAMIC JLABElS(say 5)..yes i know it sounds easy
but i also have to give them Events n then want to refer each of them when ever Mouse is Clicked on a Specific Label with its Label Name or Text..
i tried it by...
n then calling it in MouseClicked event..
but this is not giving me the REsult..as this alwayz prints 5 (i.e LAST JLABELS setText..
PLZ help!!!need Urgently..
thankz is Advance
Cheerz!!
i need to create DYNAMIC JLABElS(say 5)..yes i know it sounds easy
but i also have to give them Events n then want to refer each of them when ever Mouse is Clicked on a Specific Label with its Label Name or Text..
i tried it by...
Code:
Object lbl_name
for(n1=1;n1<=5;n1++)
{
lbl_name = new String("lbl_cal");
lbl_name = new JLabel();
((JLabel)lbl_name).setName(lbl_name.toString());
panel1.add((JLabel) lbl_name, new org.netbeans.lib.awtextra.AbsoluteConstraints(x, y, 40, 20));
((JLabel)lbl_name).addMouseListener(this);
((JLabel)lbl_name).setText(n1);
x = x+10;
y = y+2;
}
n then calling it in MouseClicked event..
Code:
public void mouseClicked(MouseEvent me)
{
System.out.println("CLICKED on Label..." + ((JLabel)lbl_name).getText());
}
PLZ help!!!need Urgently..
thankz is Advance
Cheerz!!
Comment