Originally posted by pete stein:
why do you need the source? And again, why are you trying to subclass it? As mentioned, composition may be better than inheritance.
just search the java site for the source. it shouldn't be hard to find.
[ September 01, 2007: Message edited by: pete stein ]
Good question,
I declare
NewEmployee selectedLabel;
here, NewEmployee.java class extends JLabel{}
As we know, in the method,
public void mousePressed(MouseEvent e) {
.......
Component[] c = ((JComponent)e.getSource()).getComponents();
}
Because I add several JLabels in JPanel, then Array c now gets all JLabels in it,
and NewEmployee.java has some custom methods I need but JLabel.java class does not have them such as getEmployeeName(), setEmployeeName() etc, here NewEmployee.java subclass JLabel class, so when I cast :
selectedLabel = (NewEmployee)c[i];
It throws errors as follows:
javax.swing.JLabel cannot be cast to atest.NewEmployee...
So how to solve this problem??
Thanks
[ September 01, 2007: Message edited by: Michelle Wang ]