Identificationd'un element java.awt .(suite)

marty25 Messages postés 56 Statut Membre -  
choubaka Messages postés 39986 Date d'inscription   Statut Modérateur Dernière intervention   -
Re,

voici le code de ma methode action():

public boolean action(Event evt, Object arg)
{
if(evt.target instanceof Choice)
{
try{

return handleChoix(arg);
}catch(Exception e){return false;}
}//end if
else if(evt.target instanceof Button)
{
try{
return handleButton();
}catch(Exception e){return false;}
}//end if
else {return false;}
}//end action

Voila voila :)
Re-merci :)
Marty(...)

1 réponse

choubaka Messages postés 39986 Date d'inscription   Statut Modérateur Dernière intervention   2 106
 
alors voilà une solution élégante

Button myButton1 = new Button();
myButton1.addActionListener((new ActionListener() {
public void actionPerformed(ActionEvent evt) {
methodForButton1();
}
}
);

Button myButton2 = new Button();
myButton1.addActionListener((new ActionListener() {
public void actionPerformed(ActionEvent evt) {
methodForButton2();
}
}
);

private boolean methodForButton1(){

return le boolean resultat sur l'action du Button 1;

}

private boolean methodForButton2(){

return le boolean resultat sur l'action du Button 2;

}

ça devrait marcher

" Jusqu'où s'arrêteront-t'ils?"
0