GuiTranslationExampleController.java

/*
 * @author Hermann Wöhrmann
 *
 * Description:
 *
 * Version Date       Comments
 * 1.01.01 07.11.2004 created
 *
 */

import java.awt.event.*;
import javax.swing.*;
//import speed.jg.*;

public class GuiTranslationExampleController implements ActionListener, ItemListener, WindowListener
{ GUIObject gui;
  JFrame guiTranslationExample;
  JMenuItem fmExit;
  JRadioButtonMenuItem tmEnglish;
  JRadioButtonMenuItem tmGerman;

  GuiTranslationExampleController(GUIObject guiObject)
  { this.gui = guiObject;
    fmExit = (JMenuItem)gui.getComponent("fmExit");
    fmExit.addActionListener(this);
    guiTranslationExample = (JFrame)gui.getComponent("guiTranslationExample");
    guiTranslationExample.addWindowListener(this);
    tmEnglish = (JRadioButtonMenuItem)gui.getComponent("tmEnglish");
    tmEnglish.addItemListener(this);
    tmGerman = (JRadioButtonMenuItem)gui.getComponent("tmGerman");
    tmGerman.addItemListener(this);
    initialize();
  }

//==============================================================================
// Implementing the ActionListener Interface ...
//------------------------------------------------------------------------------

  public void actionPerformed(ActionEvent e)
  { try
    { Object component = e.getSource();
      if (component.equals(fmExit)) handleFmExitActionPerformedEvent(e);
    }
    catch (Exception ex)
    { // in order to avoid throwing exceptions into the event-dispatching thread
      ex.printStackTrace(System.err);
    }
  }

//==============================================================================
// Implementing the ItemListener Interface ...
//------------------------------------------------------------------------------

  public void itemStateChanged(ItemEvent e)
  { try
    { Object component = e.getSource();
      if (component.equals(tmEnglish)) handleTmEnglishItemStateChangedEvent(e);
      else if (component.equals(tmGerman)) handleTmGermanItemStateChangedEvent(e);
    }
    catch (Exception ex)
    { // in order to avoid throwing exceptions into the event-dispatching thread
      ex.printStackTrace(System.err);
    }
  }

//==============================================================================
// Implementing the WindowListener Interface ...
//------------------------------------------------------------------------------

  public void windowOpened(WindowEvent e)
  { try
    { Object component = e.getSource();
      if (component.equals(guiTranslationExample)) handleGuiTranslationExampleWindowOpenedEvent(e);
    }
    catch (Exception ex)
    { // in order to avoid throwing exceptions into the event-dispatching thread
      ex.printStackTrace(System.err);
    }
  }

//------------------------------------------------------------------------------

  public void windowActivated(WindowEvent e)
  { try
    { Object component = e.getSource();
      if (component.equals(guiTranslationExample)) handleGuiTranslationExampleWindowActivatedEvent(e);
    }
    catch (Exception ex)
    { // in order to avoid throwing exceptions into the event-dispatching thread
      ex.printStackTrace(System.err);
    }
  }

//------------------------------------------------------------------------------

  public void windowDeactivated(WindowEvent e)
  { try
    { Object component = e.getSource();
      if (component.equals(guiTranslationExample)) handleGuiTranslationExampleWindowDeactivatedEvent(e);
    }
    catch (Exception ex)
    { // in order to avoid throwing exceptions into the event-dispatching thread
      ex.printStackTrace(System.err);
    }
  }

//------------------------------------------------------------------------------

  public void windowClosing(WindowEvent e)
  { try
    { Object component = e.getSource();
      if (component.equals(guiTranslationExample)) handleGuiTranslationExampleWindowClosingEvent(e);
    }
    catch (Exception ex)
    { // in order to avoid throwing exceptions into the event-dispatching thread
      ex.printStackTrace(System.err);
    }
  }

//------------------------------------------------------------------------------

  public void windowClosed(WindowEvent e)
  { try
    { Object component = e.getSource();
      if (component.equals(guiTranslationExample)) handleGuiTranslationExampleWindowClosedEvent(e);
    }
    catch (Exception ex)
    { // in order to avoid throwing exceptions into the event-dispatching thread
      ex.printStackTrace(System.err);
    }
  }

//------------------------------------------------------------------------------

  public void windowIconified(WindowEvent e)
  { try
    { Object component = e.getSource();
      if (component.equals(guiTranslationExample)) handleGuiTranslationExampleWindowIconifiedEvent(e);
    }
    catch (Exception ex)
    { // in order to avoid throwing exceptions into the event-dispatching thread
      ex.printStackTrace(System.err);
    }
  }

//------------------------------------------------------------------------------

  public void windowDeiconified(WindowEvent e)
  { try
    { Object component = e.getSource();
      if (component.equals(guiTranslationExample)) handleGuiTranslationExampleWindowDeiconifiedEvent(e);
    }
    catch (Exception ex)
    { // in order to avoid throwing exceptions into the event-dispatching thread
      ex.printStackTrace(System.err);
    }
  }

//==============================================================================
// Customize event-handling within the following methods ...
//------------------------------------------------------------------------------

  void initialize()
  { // System.out.println("initialize()");
  }

//==============================================================================
// ActionListener event handling ...
//------------------------------------------------------------------------------

  void handleFmExitActionPerformedEvent(ActionEvent e) throws Exception
  { // System.out.println("handleFmExitActionPerformedEvent");
  }

//==============================================================================
// ItemListener event handling ...
//------------------------------------------------------------------------------

  void handleTmEnglishItemStateChangedEvent(ItemEvent e) throws Exception
  { // System.out.println("handleTmEnglishItemStateChangedEvent");
  }

  void handleTmGermanItemStateChangedEvent(ItemEvent e) throws Exception
  { // System.out.println("handleTmGermanItemStateChangedEvent");
  }

//==============================================================================
// WindowListener event handling ...
//------------------------------------------------------------------------------

  void handleGuiTranslationExampleWindowOpenedEvent(WindowEvent e) throws Exception
  { // System.out.println("handleGuiTranslationExampleWindowOpenedEvent");
  }

//------------------------------------------------------------------------------

  void handleGuiTranslationExampleWindowActivatedEvent(WindowEvent e) throws Exception
  { // System.out.println("handleGuiTranslationExampleWindowActivatedEvent");
  }

//------------------------------------------------------------------------------

  void handleGuiTranslationExampleWindowDeactivatedEvent(WindowEvent e) throws Exception
  { // System.out.println("handleGuiTranslationExampleWindowDeactivatedEvent");
  }

//------------------------------------------------------------------------------

  void handleGuiTranslationExampleWindowClosingEvent(WindowEvent e) throws Exception
  { // System.out.println("handleGuiTranslationExampleWindowClosingEvent");
  }

//------------------------------------------------------------------------------

  void handleGuiTranslationExampleWindowClosedEvent(WindowEvent e) throws Exception
  { // System.out.println("handleGuiTranslationExampleWindowClosedEvent");
  }

//------------------------------------------------------------------------------

  void handleGuiTranslationExampleWindowIconifiedEvent(WindowEvent e) throws Exception
  { // System.out.println("handleGuiTranslationExampleWindowIconifiedEvent");
  }

//------------------------------------------------------------------------------

  void handleGuiTranslationExampleWindowDeiconifiedEvent(WindowEvent e) throws Exception
  { // System.out.println("handleGuiTranslationExampleWindowDeiconifiedEvent");
  }

//==== EOF =====================================================================

}