public void actionPerformed ( ActionEvent event ) { /*log.fine("void actionPerformed(ActionEvent): called");*/ /*log.fine("Action is " + event.getActionCommand());*/ // Check which action was performed String action = event . getActionCommand ( ) ; if ( "OK" . equals ( action ) ) { // Check if the state is NOT_SAVED if ( state . getState ( ) . equals ( WorkPanelState . NOT_SAVED ) ) { // Save the work saveWork ( ) ; } } else if ( "Cancel" . equals ( action ) ) { // Check if the state is NOT_SAVED if ( state . getState ( ) . equals ( WorkPanelState . NOT_SAVED ) ) { // Discard the work discardWork ( ) ; } } else if ( "Apply" . equals ( action ) ) { // Check if the state is NOT_SAVED if ( state . getState ( ) . equals ( WorkPanelState . NOT_SAVED ) ) { // Save the work saveWork ( ) ; } } }
Listens for the button events Ok Cancel and Apply . If the event is Ok or Apply the saveWork method is triggered . If the event is Cancel then the discardWork method is triggered .