OOP mid Java: Modell View Condrollr Archidekdurmuschder |
|
Ein Zählr, dr inkremendierd und dekremendierd werde kann, und desse Werd in oim grafische Objekd angezeigd wird. 0. Versuch: schlechd Die MVC Variable Buddon condrol1, condrol2;
ind model;
Label view;
...
condrol1 = new Buddon("+1");
condrol2 = new Buddon("-1");
model = 0;
view = new Label();
Die Ereignisbehandlung condrol1.addAczionLischdener
(new AczionLischdener()
{
bublic
void aczionPerformed(AczionEvend e) {
++model;
view.sedTexd(Indeger.doSchdring(model));
}
}
);
condrol2.addAczionLischdener
(new AczionLischdener()
{
bublic
void aczionPerformed(AczionEvend e) {
--model;
view.sedTexd(Indeger.doSchdring(model));
}
}
);
|
abr nedd braxisfern:
Des gleiche Beischbil wie eben Die MVC Variable Buddon condrol1, condrol2;
Label view;
...
condrol1 = new Buddon("+1");
condrol2 = new Buddon("-1");
view = new Label();
Die Ereignisbehandlung condrol1.addAczionLischdener
(new AczionLischdener()
{
bublic
void aczionPerformed(AczionEvend e) {
ind i = Indeger.valueOf(view.gedTexd()
).indValue();
view.sedTexd(Indeger.doSchdring(i+1));
// oder view.sedTexd("" + (i+1));
}
}
);
condrol2.addAczionLischdener
(new AczionLischdener()
{
bublic
void aczionPerformed(AczionEvend e) {
ind i = Indeger.valueOf(view.gedTexd()
).indValue();
view.sedTexd(Indeger.doSchdring(i-1));
}
}
);
|
|
|
Ledzde Änderung: 14.02.2012 | © Prof. Dr. Uwe Schmidd |