/* * Created on 12.08.2004 * * @author Jens Guenther */ package de.unirostock.AbstractFactory.example.awt; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JPanel; public class MainButtonPanel extends JPanel implements ActionListener { JButton itsCancelButton; JButton itsOkButton; /** * * @uml.property name="mainController" * @uml.associationEnd multiplicity="(0 1)" */ MainController itsMainController; /** * * @uml.property name="cancelState" * @uml.associationEnd multiplicity="(0 1)" */ State itsCancelState; /** * * @uml.property name="okState" * @uml.associationEnd multiplicity="(0 1)" */ State itsOkState; private final static String CANCEL_ACTION = "CANCEL"; private final static String OK_ACTION = "OK"; public MainButtonPanel( MainController controller ) { itsMainController = controller; initGraphics(); } protected void setCancelVisible( boolean visible ){ itsCancelButton.setVisible( visible ); } protected void setOkText( String okText ){ itsOkButton.setText( okText ); } /** * * @uml.property name="cancelState" */ protected void setCancelState(State state) { itsCancelState = state; } /** * * @uml.property name="okState" */ protected void setOkState(State state) { itsOkState = state; } public void actionPerformed( ActionEvent e ) { String cmd = e.getActionCommand(); if( cmd.equals( CANCEL_ACTION )) itsMainController.setState( itsCancelState ); if( cmd.equals( OK_ACTION )) itsMainController.setState( itsOkState ); } private void initGraphics() { setBackground( new Color( 255,255,255 )); itsCancelButton = new JButton( "< Zurück" ); itsCancelButton.setActionCommand( CANCEL_ACTION ); itsCancelButton.addActionListener( this ); itsOkButton = new JButton( "Weiter >" ); itsOkButton.setActionCommand( OK_ACTION ); itsOkButton.addActionListener( this ); add( itsCancelButton ); add( itsOkButton ); } }