MyBookshelfController.java
/*
* @author Hermann Wöhrmann
*
* Description:
*
* Version Date Comments
* 1.01.01 03.11.2004 created
*
*/
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import speed.jg.*;
public class MyBookshelfController implements ActionListener, KeyListener, MenuListener, TreeSelectionListener, WindowListener
{ GUIObject gui;
JButton btnAdd;
JButton btnChange;
JButton btnRemove;
JFrame myBookshelf;
JMenu fileMenu;
JMenuItem exitMenuItem;
JTextArea taDescription;
JTextArea xmlTextArea;
JTextField tfPrice;
JTextField tfTitle;
JTree bookshelfTree;
MyBookshelfController(GUIObject guiObject)
{ this.gui = guiObject;
bookshelfTree = (JTree)gui.getComponent("bookshelfTree");
bookshelfTree.addTreeSelectionListener(this);
btnAdd = (JButton)gui.getComponent("btnAdd");
btnAdd.addActionListener(this);
btnChange = (JButton)gui.getComponent("btnChange");
btnChange.addActionListener(this);
btnRemove = (JButton)gui.getComponent("btnRemove");
btnRemove.addActionListener(this);
exitMenuItem = (JMenuItem)gui.getComponent("exitMenuItem");
exitMenuItem.addActionListener(this);
fileMenu = (JMenu)gui.getComponent("fileMenu");
fileMenu.addMenuListener(this);
myBookshelf = (JFrame)gui.getComponent("myBookshelf");
myBookshelf.addWindowListener(this);
taDescription = (JTextArea)gui.getComponent("taDescription");
taDescription.addKeyListener(this);
tfPrice = (JTextField)gui.getComponent("tfPrice");
tfPrice.addKeyListener(this);
tfTitle = (JTextField)gui.getComponent("tfTitle");
tfTitle.addKeyListener(this);
xmlTextArea = (JTextArea)gui.getComponent("xmlTextArea");
xmlTextArea.addKeyListener(this);
initialize();
}
//==============================================================================
// Implementing the ActionListener Interface ...
//------------------------------------------------------------------------------
public void actionPerformed(ActionEvent e)
{ try
{ Object component = e.getSource();
if (component.equals(btnAdd)) handleBtnAddActionPerformedEvent(e);
else if (component.equals(btnChange)) handleBtnChangeActionPerformedEvent(e);
else if (component.equals(btnRemove)) handleBtnRemoveActionPerformedEvent(e);
else if (component.equals(exitMenuItem)) handleExitMenuItemActionPerformedEvent(e);
}
catch (Exception ex)
{ // in order to avoid throwing exceptions into the event-dispatching thread
ex.printStackTrace(System.err);
}
}
//==============================================================================
// Implementing the KeyListener Interface ...
//------------------------------------------------------------------------------
public void keyTyped(KeyEvent e)
{ try
{ Object component = e.getSource();
if (component.equals(taDescription)) handleTaDescriptionKeyTypedEvent(e);
else if (component.equals(tfPrice)) handleTfPriceKeyTypedEvent(e);
else if (component.equals(tfTitle)) handleTfTitleKeyTypedEvent(e);
else if (component.equals(xmlTextArea)) handleXmlTextAreaKeyTypedEvent(e);
}
catch (Exception ex)
{ // in order to avoid throwing exceptions into the event-dispatching thread
ex.printStackTrace(System.err);
}
}
//------------------------------------------------------------------------------
public void keyPressed(KeyEvent e)
{ try
{ Object component = e.getSource();
if (component.equals(taDescription)) handleTaDescriptionKeyPressedEvent(e);
else if (component.equals(tfPrice)) handleTfPriceKeyPressedEvent(e);
else if (component.equals(tfTitle)) handleTfTitleKeyPressedEvent(e);
else if (component.equals(xmlTextArea)) handleXmlTextAreaKeyPressedEvent(e);
}
catch (Exception ex)
{ // in order to avoid throwing exceptions into the event-dispatching thread
ex.printStackTrace(System.err);
}
}
//------------------------------------------------------------------------------
public void keyReleased(KeyEvent e)
{ try
{ Object component = e.getSource();
if (component.equals(taDescription)) handleTaDescriptionKeyReleasedEvent(e);
else if (component.equals(tfPrice)) handleTfPriceKeyReleasedEvent(e);
else if (component.equals(tfTitle)) handleTfTitleKeyReleasedEvent(e);
else if (component.equals(xmlTextArea)) handleXmlTextAreaKeyReleasedEvent(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(fileMenu)) handleFileMenuMenuSelectedEvent(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(fileMenu)) handleFileMenuMenuDeselectedEvent(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(fileMenu)) handleFileMenuMenuCanceledEvent(e);
}
catch (Exception ex)
{ // in order to avoid throwing exceptions into the event-dispatching thread
ex.printStackTrace(System.err);
}
}
//==============================================================================
// Implementing the TreeSelectionListener Interface ...
//------------------------------------------------------------------------------
public void valueChanged(TreeSelectionEvent e)
{ try
{ Object component = e.getSource();
if (component.equals(bookshelfTree)) handleBookshelfTreeValueChangedEvent(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(myBookshelf)) handleMyBookshelfWindowOpenedEvent(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(myBookshelf)) handleMyBookshelfWindowActivatedEvent(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(myBookshelf)) handleMyBookshelfWindowDeactivatedEvent(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(myBookshelf)) handleMyBookshelfWindowClosingEvent(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(myBookshelf)) handleMyBookshelfWindowClosedEvent(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(myBookshelf)) handleMyBookshelfWindowIconifiedEvent(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(myBookshelf)) handleMyBookshelfWindowDeiconifiedEvent(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 handleBtnAddActionPerformedEvent(ActionEvent e) throws Exception
{ // System.out.println("handleBtnAddActionPerformedEvent");
}
void handleBtnChangeActionPerformedEvent(ActionEvent e) throws Exception
{ // System.out.println("handleBtnChangeActionPerformedEvent");
}
void handleBtnRemoveActionPerformedEvent(ActionEvent e) throws Exception
{ // System.out.println("handleBtnRemoveActionPerformedEvent");
}
void handleExitMenuItemActionPerformedEvent(ActionEvent e) throws Exception
{ // System.out.println("handleExitMenuItemActionPerformedEvent");
}
//==============================================================================
// KeyListener event handling ...
//------------------------------------------------------------------------------
void handleTaDescriptionKeyTypedEvent(KeyEvent e) throws Exception
{ // System.out.println("handleTaDescriptionKeyTypedEvent");
}
void handleTfPriceKeyTypedEvent(KeyEvent e) throws Exception
{ // System.out.println("handleTfPriceKeyTypedEvent");
}
void handleTfTitleKeyTypedEvent(KeyEvent e) throws Exception
{ // System.out.println("handleTfTitleKeyTypedEvent");
}
void handleXmlTextAreaKeyTypedEvent(KeyEvent e) throws Exception
{ // System.out.println("handleXmlTextAreaKeyTypedEvent");
}
//------------------------------------------------------------------------------
void handleTaDescriptionKeyPressedEvent(KeyEvent e) throws Exception
{ // System.out.println("handleTaDescriptionKeyPressedEvent");
}
void handleTfPriceKeyPressedEvent(KeyEvent e) throws Exception
{ // System.out.println("handleTfPriceKeyPressedEvent");
}
void handleTfTitleKeyPressedEvent(KeyEvent e) throws Exception
{ // System.out.println("handleTfTitleKeyPressedEvent");
}
void handleXmlTextAreaKeyPressedEvent(KeyEvent e) throws Exception
{ // System.out.println("handleXmlTextAreaKeyPressedEvent");
}
//------------------------------------------------------------------------------
void handleTaDescriptionKeyReleasedEvent(KeyEvent e) throws Exception
{ // System.out.println("handleTaDescriptionKeyReleasedEvent");
}
void handleTfPriceKeyReleasedEvent(KeyEvent e) throws Exception
{ // System.out.println("handleTfPriceKeyReleasedEvent");
}
void handleTfTitleKeyReleasedEvent(KeyEvent e) throws Exception
{ // System.out.println("handleTfTitleKeyReleasedEvent");
}
void handleXmlTextAreaKeyReleasedEvent(KeyEvent e) throws Exception
{ // System.out.println("handleXmlTextAreaKeyReleasedEvent");
}
//==============================================================================
// MenuListener event handling ...
//------------------------------------------------------------------------------
void handleFileMenuMenuSelectedEvent(MenuEvent e) throws Exception
{ // System.out.println("handleFileMenuMenuSelectedEvent");
}
//------------------------------------------------------------------------------
void handleFileMenuMenuDeselectedEvent(MenuEvent e) throws Exception
{ // System.out.println("handleFileMenuMenuDeselectedEvent");
}
//------------------------------------------------------------------------------
void handleFileMenuMenuCanceledEvent(MenuEvent e) throws Exception
{ // System.out.println("handleFileMenuMenuCanceledEvent");
}
//==============================================================================
// TreeSelectionListener event handling ...
//------------------------------------------------------------------------------
void handleBookshelfTreeValueChangedEvent(TreeSelectionEvent e) throws Exception
{ // System.out.println("handleBookshelfTreeValueChangedEvent");
}
//==============================================================================
// WindowListener event handling ...
//------------------------------------------------------------------------------
void handleMyBookshelfWindowOpenedEvent(WindowEvent e) throws Exception
{ // System.out.println("handleMyBookshelfWindowOpenedEvent");
}
//------------------------------------------------------------------------------
void handleMyBookshelfWindowActivatedEvent(WindowEvent e) throws Exception
{ // System.out.println("handleMyBookshelfWindowActivatedEvent");
}
//------------------------------------------------------------------------------
void handleMyBookshelfWindowDeactivatedEvent(WindowEvent e) throws Exception
{ // System.out.println("handleMyBookshelfWindowDeactivatedEvent");
}
//------------------------------------------------------------------------------
void handleMyBookshelfWindowClosingEvent(WindowEvent e) throws Exception
{ // System.out.println("handleMyBookshelfWindowClosingEvent");
}
//------------------------------------------------------------------------------
void handleMyBookshelfWindowClosedEvent(WindowEvent e) throws Exception
{ // System.out.println("handleMyBookshelfWindowClosedEvent");
}
//------------------------------------------------------------------------------
void handleMyBookshelfWindowIconifiedEvent(WindowEvent e) throws Exception
{ // System.out.println("handleMyBookshelfWindowIconifiedEvent");
}
//------------------------------------------------------------------------------
void handleMyBookshelfWindowDeiconifiedEvent(WindowEvent e) throws Exception
{ // System.out.println("handleMyBookshelfWindowDeiconifiedEvent");
}
//==== EOF =====================================================================
}