Enumeration e = mot.VPersonnes.elements();
while(e.hasMoreElements())
{
Object obj;
obj = e.nextElement();
jCBPers.addItem( ( (obj.getClass()) obj.GetIdentifiant()).GetID() );
//jCBPers.addItem( ( ( (PersonnelScientifique) e.nextElement()).GetIdentifiant()).GetID() ); //It's working with STATIC CASTING !!!!
}
The sub-class of Persons (the class that are in the vector) IMPLEMENT Interface "EstIdentifiable".
The differents Persons have 1 "ID".
ID is an instance of the class "Matricule".
Matricule IMPLEMENT Interface "Identifiant"
And
interface EstIdentifiable got this method :
public String GetIdentifiant();
and
interface Identifiant got this method:
public String GetID();
When i do :
String ID = aRichPerson.GetIdentifiant().GetID();
The id is correctly returned !
In my example, I need to CAST the object "obj" in the correct Class to reach the GetIdentifiant().GetID() methods.