MyJFrameController.java

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

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

public class MyJFrameController implements ActionListener, InternalFrameListener, MenuListener, PopupMenuListener, WindowListener
{ GUIObject gui;
  JButton btnNew;
  JButton btnOpen;
  JButton myJButton;
  JFrame myJFrame;
  JInternalFrame myJInternalFrame;
  JMenu myJMenu;
  JMenuItem mnClose;
  JMenuItem mnExit;
  JMenuItem mnNew;
  JMenuItem mnOpen;
  JMenuItem popClose;
  JMenuItem popExit;
  JMenuItem popNew;
  JMenuItem popOpen;
  JPopupMenu myJPopupMenu;

  MyJFrameController(GUIObject guiObject)
  { this.gui = guiObject;
    btnNew = (JButton)gui.getComponent("btnNew");
    btnNew.addActionListener(this);
    btnOpen = (JButton)gui.getComponent("btnOpen");
    btnOpen.addActionListener(this);
    mnClose = (JMenuItem)gui.getComponent("mnClose");
    mnClose.addActionListener(this);
    mnExit = (JMenuItem)gui.getComponent("mnExit");
    mnExit.addActionListener(this);
    mnNew = (JMenuItem)gui.getComponent("mnNew");
    mnNew.addActionListener(this);
    mnOpen = (JMenuItem)gui.getComponent("mnOpen");
    mnOpen.addActionListener(this);
    myJButton = (JButton)gui.getComponent("myJButton");
    myJButton.addActionListener(this);
    myJFrame = (JFrame)gui.getComponent("myJFrame");
    myJFrame.addWindowListener(this);
    myJInternalFrame = (JInternalFrame)gui.getComponent("myJInternalFrame");
    myJInternalFrame.addInternalFrameListener(this);
    myJMenu = (JMenu)gui.getComponent("myJMenu");
    myJMenu.addMenuListener(this);
    myJPopupMenu = (JPopupMenu)gui.getComponent("myJPopupMenu");
    myJPopupMenu.addPopupMenuListener(this);
    popClose = (JMenuItem)gui.getComponent("popClose");
    popClose.addActionListener(this);
    popExit = (JMenuItem)gui.getComponent("popExit");
    popExit.addActionListener(this);
    popNew = (JMenuItem)gui.getComponent("popNew");
    popNew.addActionListener(this);
    popOpen = (JMenuItem)gui.getComponent("popOpen");
    popOpen.addActionListener(this);
    initialize();
  }

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

  public void actionPerformed(ActionEvent e)
  { try
    { Object component = e.getSource();
      if (component.equals(btnNew)) handleBtnNewActionPerformedEvent(e);
      else if (component.equals(btnOpen)) handleBtnOpenActionPerformedEvent(e);
      else if (component.equals(mnClose)) handleMnCloseActionPerformedEvent(e);
      else if (component.equals(mnExit)) handleMnExitActionPerformedEvent(e);
      else if (component.equals(mnNew)) handleMnNewActionPerformedEvent(e);
      else if (component.equals(mnOpen)) handleMnOpenActionPerformedEvent(e);
      else if (component.equals(myJButton)) handleMyJButtonActionPerformedEvent(e);
      else if (component.equals(popClose)) handlePopCloseActionPerformedEvent(e);
      else if (component.equals(popExit)) handlePopExitActionPerformedEvent(e);
      else if (component.equals(popNew)) handlePopNewActionPerformedEvent(e);
      else if (component.equals(popOpen)) handlePopOpenActionPerformedEvent(e);
    }
    catch (Exception ex)
    { // in order to avoid throwing exceptions into the event-dispatching thread
      ex.printStackTrace(System.err);
    }
  }

//==============================================================================
// Implementing the InternalFrameListener Interface ...
//------------------------------------------------------------------------------

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

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

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

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

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

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

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

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

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

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

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

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

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

//==============================================================================
// Implementing the MenuListener Interface ...
//------------------------------------------------------------------------------

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

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

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

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

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

//==============================================================================
// Implementing the PopupMenuListener Interface ...
//------------------------------------------------------------------------------

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

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

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

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

  public void popupMenuCanceled(PopupMenuEvent e)
  { try
    { Object component = e.getSource();
      if (component.equals(myJPopupMenu)) handleMyJPopupMenuPopupMenuCanceledEvent(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(myJFrame)) handleMyJFrameWindowOpenedEvent(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(myJFrame)) handleMyJFrameWindowActivatedEvent(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(myJFrame)) handleMyJFrameWindowDeactivatedEvent(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(myJFrame)) handleMyJFrameWindowClosingEvent(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(myJFrame)) handleMyJFrameWindowClosedEvent(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(myJFrame)) handleMyJFrameWindowIconifiedEvent(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(myJFrame)) handleMyJFrameWindowDeiconifiedEvent(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 handleBtnNewActionPerformedEvent(ActionEvent e) throws Exception
  { // System.out.println("handleBtnNewActionPerformedEvent");
  }

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

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

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

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

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

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

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

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

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

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

//==============================================================================
// InternalFrameListener event handling ...
//------------------------------------------------------------------------------

  void handleMyJInternalFrameInternalFrameOpenedEvent(InternalFrameEvent e) throws Exception
  { // System.out.println("handleMyJInternalFrameInternalFrameOpenedEvent");
  }

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

  void handleMyJInternalFrameInternalFrameActivatedEvent(InternalFrameEvent e) throws Exception
  { // System.out.println("handleMyJInternalFrameInternalFrameActivatedEvent");
  }

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

  void handleMyJInternalFrameInternalFrameDeactivatedEvent(InternalFrameEvent e) throws Exception
  { // System.out.println("handleMyJInternalFrameInternalFrameDeactivatedEvent");
  }

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

  void handleMyJInternalFrameInternalFrameClosingEvent(InternalFrameEvent e) throws Exception
  { // System.out.println("handleMyJInternalFrameInternalFrameClosingEvent");
  }

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

  void handleMyJInternalFrameInternalFrameClosedEvent(InternalFrameEvent e) throws Exception
  { // System.out.println("handleMyJInternalFrameInternalFrameClosedEvent");
  }

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

  void handleMyJInternalFrameInternalFrameIconifiedEvent(InternalFrameEvent e) throws Exception
  { // System.out.println("handleMyJInternalFrameInternalFrameIconifiedEvent");
  }

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

  void handleMyJInternalFrameInternalFrameDeiconifiedEvent(InternalFrameEvent e) throws Exception
  { // System.out.println("handleMyJInternalFrameInternalFrameDeiconifiedEvent");
  }

//==============================================================================
// MenuListener event handling ...
//------------------------------------------------------------------------------

  void handleMyJMenuMenuSelectedEvent(MenuEvent e) throws Exception
  { // System.out.println("handleMyJMenuMenuSelectedEvent");
  }

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

  void handleMyJMenuMenuDeselectedEvent(MenuEvent e) throws Exception
  { // System.out.println("handleMyJMenuMenuDeselectedEvent");
  }

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

  void handleMyJMenuMenuCanceledEvent(MenuEvent e) throws Exception
  { // System.out.println("handleMyJMenuMenuCanceledEvent");
  }

//==============================================================================
// PopupMenuListener event handling ...
//------------------------------------------------------------------------------

  void handleMyJPopupMenuPopupMenuWillBecomeVisibleEvent(PopupMenuEvent e) throws Exception
  { // System.out.println("handleMyJPopupMenuPopupMenuWillBecomeVisibleEvent");
  }

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

  void handleMyJPopupMenuPopupMenuWillBecomeInvisibleEvent(PopupMenuEvent e) throws Exception
  { // System.out.println("handleMyJPopupMenuPopupMenuWillBecomeInvisibleEvent");
  }

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

  void handleMyJPopupMenuPopupMenuCanceledEvent(PopupMenuEvent e) throws Exception
  { // System.out.println("handleMyJPopupMenuPopupMenuCanceledEvent");
  }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

}