11.07.2015 Views

Les IHM en java - Free

Les IHM en java - Free

Les IHM en java - Free

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}**** addWindowList<strong>en</strong>er(new FermeF<strong>en</strong>etre) ***// apparitionpack();setVisible(true);public void actionPerformed(ActionEv<strong>en</strong>t e){}if(e.getSource().equals(bPour))elsecPour.incr();cContre().incr();lRes.setText("Resultats : " + (100*cPour.valeur())/(cPour.valeur() +cContre.valeur()) + "% pour");}public static void main(String args[]){}new Sondage();Deux remarques :1) Stratégie du "actionPerformed" unique pas valable si <strong>IHM</strong> complexe2) La f<strong>en</strong>être ne se ferme pas ! (pas de WindowList<strong>en</strong>er)idée 1 : Sondage implem<strong>en</strong>te WindowList<strong>en</strong>erpublic void windowClosing(WindowEv<strong>en</strong>t e){System.exit(0);}pb : ne compile pas.-> 11 méthodes à écrireidée 2 : utiliser un "adapter" qui wrappe les méthodes du list<strong>en</strong>er <strong>en</strong> ne faisant ri<strong>en</strong>.Pb : Sondage ne peut pas hériter de Frame et de WindowAdapter.-> Il faut donc passer par une classe intermédiairepublic class FermeF<strong>en</strong>etre ext<strong>en</strong>ds WindowAdapter{public void windowClosing(WindowEv<strong>en</strong>t e){System.exit(0);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!