Hallo,
kann ich einen Oberserver nur für eine einzige Aktion verwenden? Gibt ja nur eine update Methode?
kann ich einen Oberserver nur für eine einzige Aktion verwenden? Gibt ja nur eine update Methode?
public class MultiViewZoom_ActionListener implements ActionListener {
public static final int ACTION_ZOOM_IN = 1;
public static final int ACTION_ZOOM_OUT = 2;
public static final int ACTION_ZOOM_NORMAL = 3;
private MultiView view;
private int action;
public MultiViewZoom_ActionListener(MultiView view, int action) {
this.view = view;
this.action = action;
}
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e) {
switch (action) {
case ACTION_ZOOM_IN: {
view.zoomIn();
break;
}
case ACTION_ZOOM_OUT: {
view.zoomOut();
break;
}
case ACTION_ZOOM_NORMAL: {
view.zoomNormal();
break;
}
default:
// Fehlermeldung, weil Action nicht definiert/ausgewertet
}
}
}
button_view1_zoomIn.addActionListener(new MultiViewZoom_ActionListener(view1), MultiViewZoom_ActionListener.ACTION_ZOOM_IN));
...oder willst...das angesprochenen Listener Prinzip müsstes du selbst implementieren, wenn du nicht eine der vorhandenen Listener nutzen kannst !