// ==========================================================================
// $Id: TimerClockFrame.java,v 1.4 2002/09/09 09:24:35 hitoshi Exp $
// Timer Clock Frame
// ==========================================================================
// Copyright (C) 2002 Yamauchi, Hitoshi
//
//   Max-Planck-Institut fuer Informatik AG4
//   Stuhlsatzenhausweg 85, 66123 Saarbruecken
//   http://www.mpi-sb.mpg.de/
// 
// This software can be redistributed only under GNU copyleft.
//
// @author Yamauchi Hitoshi »³Æâ ÀÆ
// ==========================================================================
// $Revision: 1.4 $
// $Date: 2002/09/09 09:24:35 $
// $Author: hitoshi $
// ==========================================================================
package de.mpg.mpisb.timerclock;

/**
 * Time Clock
 * @author Yamauchi Hitoshi
 */
public class TimerClockFrame extends javax.swing.JFrame {

    /** Creates new form Application */
    public TimerClockFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        menuBar = new javax.swing.JMenuBar();
        mFileMenu = new javax.swing.JMenu();
        mAboutMI = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        mSetting = new javax.swing.JMenu();
        mFontMI = new javax.swing.JMenuItem();
        mFGColorMI = new javax.swing.JMenuItem();
        mBGColorMI = new javax.swing.JMenuItem();
        mResetColor = new javax.swing.JMenuItem();
        mSetTime = new javax.swing.JMenuItem();
        mActionJM = new javax.swing.JMenu();
        mAction0MI = new javax.swing.JMenuItem();
        mAction1MI = new javax.swing.JMenuItem();
        mAction2MI = new javax.swing.JMenuItem();
        mAction3MI = new javax.swing.JMenuItem();
        mAction4MI = new javax.swing.JMenuItem();
        mControl = new javax.swing.JMenu();
        mStartCtrlMI = new javax.swing.JMenuItem();
        mStopCtrlMI = new javax.swing.JMenuItem();
        mResetCtrMI = new javax.swing.JMenuItem();
        
        mFileMenu.setText("File");
        mAboutMI.setText("About");
        mAboutMI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mAboutMIActionPerformed(evt);
            }
        });
        
        mFileMenu.add(mAboutMI);
        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        
        mFileMenu.add(exitMenuItem);
        menuBar.add(mFileMenu);
        mSetting.setText("Setting");
        mFontMI.setText("Font");
        mFontMI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mFontMIActionPerformed(evt);
            }
        });
        
        mSetting.add(mFontMI);
        mFGColorMI.setText("default FG Color");
        mFGColorMI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mFGColorMIActionPerformed(evt);
            }
        });
        
        mSetting.add(mFGColorMI);
        mBGColorMI.setText("default BG Color");
        mBGColorMI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mBGColorMIActionPerformed(evt);
            }
        });
        
        mSetting.add(mBGColorMI);
        mResetColor.setText("Reset Color");
        mResetColor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mResetColorActionPerformed(evt);
            }
        });
        
        mSetting.add(mResetColor);
        mSetTime.setText("Time");
        mSetTime.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mSetTimeActionPerformed(evt);
            }
        });
        
        mSetting.add(mSetTime);
        mActionJM.setText("Actions");
        mAction0MI.setText("Action 0");
        mAction0MI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mAction0MIActionPerformed(evt);
            }
        });
        
        mActionJM.add(mAction0MI);
        mAction1MI.setText("Action 1");
        mAction1MI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mAction1MIActionPerformed(evt);
            }
        });
        
        mActionJM.add(mAction1MI);
        mAction2MI.setText("Action 2");
        mAction2MI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mAction2MIActionPerformed(evt);
            }
        });
        
        mActionJM.add(mAction2MI);
        mAction3MI.setText("Action 3");
        mAction3MI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mAction3MIActionPerformed(evt);
            }
        });
        
        mActionJM.add(mAction3MI);
        mAction4MI.setText("Action 4");
        mAction4MI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mAction4MIActionPerformed(evt);
            }
        });
        
        mActionJM.add(mAction4MI);
        mSetting.add(mActionJM);
        menuBar.add(mSetting);
        mControl.setText("Control");
        mStartCtrlMI.setText("Start");
        mStartCtrlMI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mStartCtrlMIActionPerformed(evt);
            }
        });
        
        mControl.add(mStartCtrlMI);
        mStopCtrlMI.setText("Stop");
        mStopCtrlMI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mStopCtrlMIActionPerformed(evt);
            }
        });
        
        mControl.add(mStopCtrlMI);
        mResetCtrMI.setText("reset");
        mResetCtrMI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mResetCtrMIActionPerformed(evt);
            }
        });
        
        mControl.add(mResetCtrMI);
        menuBar.add(mControl);
        
        setTitle("Timer Clock");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });
        
        setJMenuBar(menuBar);
        pack();
    }//GEN-END:initComponents

    private void mAction4MIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mAction4MIActionPerformed
        // Add your handling code here:
      TCActions.getInstance().setAction(4);      
    }//GEN-LAST:event_mAction4MIActionPerformed

    private void mAction3MIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mAction3MIActionPerformed
        // Add your handling code here:
      TCActions.getInstance().setAction(3);      
    }//GEN-LAST:event_mAction3MIActionPerformed

    private void mAction2MIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mAction2MIActionPerformed
        // Add your handling code here:
      TCActions.getInstance().setAction(2);      
    }//GEN-LAST:event_mAction2MIActionPerformed

    private void mAction1MIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mAction1MIActionPerformed
        // Add your handling code here:
      TCActions.getInstance().setAction(1);      
    }//GEN-LAST:event_mAction1MIActionPerformed

    private void mAction0MIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mAction0MIActionPerformed
      // Add your handling code here:
      TCActions.getInstance().setAction(0);      
    }//GEN-LAST:event_mAction0MIActionPerformed

    private void mFontMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mFontMIActionPerformed
      // Add your handling code here:
      TCActions.getInstance().setFont();
    }//GEN-LAST:event_mFontMIActionPerformed

    private void mAboutMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mAboutMIActionPerformed
      // Add your handling code here:
      TCActions.getInstance().about();      
    }//GEN-LAST:event_mAboutMIActionPerformed

    private void mResetCtrMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mResetCtrMIActionPerformed
      // Add your handling code here:
      TCActions.getInstance().reset();
    }//GEN-LAST:event_mResetCtrMIActionPerformed

    private void mStopCtrlMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mStopCtrlMIActionPerformed
        // Add your handling code here:
      TCActions.getInstance().stop();      
    }//GEN-LAST:event_mStopCtrlMIActionPerformed

    private void mStartCtrlMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mStartCtrlMIActionPerformed
        // Add your handling code here:
      TCActions.getInstance().start();      
    }//GEN-LAST:event_mStartCtrlMIActionPerformed

    private void mResetColorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mResetColorActionPerformed
        // Add your handling code here:
      TCActions.getInstance().resetColor();
    }//GEN-LAST:event_mResetColorActionPerformed

    private void mSetTimeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mSetTimeActionPerformed
        // Add your handling code here:
      TCActions.getInstance().setPeriodTime();
    }//GEN-LAST:event_mSetTimeActionPerformed
  
    private void mFGColorMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mFGColorMIActionPerformed
        // Add your handling code here:
      TCActions.getInstance().setDefaultFGColor();            
    }//GEN-LAST:event_mFGColorMIActionPerformed

    private void mBGColorMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mBGColorMIActionPerformed
        // Add your handling code here:
      TCActions.getInstance().setDefaultBGColor();            
    }//GEN-LAST:event_mBGColorMIActionPerformed

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed

    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
        System.exit(0);
    }//GEN-LAST:event_exitForm

  /*
   * 
   */
  public void addPanel(javax.swing.JPanel p) 
  {
    this.getContentPane().add(p, java.awt.BorderLayout.CENTER);
    this.pack();
  }

  /**
   * @param args the command line arguments
   */
  public static void main(String args[]) 
  {
    TimerClockFrame  tcf = new TimerClockFrame();
    TimerClockPanel  tcp = new TimerClockPanel(500, 500, new TimerDowncount(6000));
    tcf.addPanel(tcp);
    tcf.setSize(500, 500);
    tcf.show();
  }

  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JMenuBar menuBar;
  private javax.swing.JMenu mFileMenu;
  private javax.swing.JMenuItem mAboutMI;
  private javax.swing.JMenuItem exitMenuItem;
  private javax.swing.JMenu mSetting;
  private javax.swing.JMenuItem mFontMI;
  private javax.swing.JMenuItem mFGColorMI;
  private javax.swing.JMenuItem mBGColorMI;
  private javax.swing.JMenuItem mResetColor;
  private javax.swing.JMenuItem mSetTime;
  private javax.swing.JMenu mActionJM;
  private javax.swing.JMenuItem mAction0MI;
  private javax.swing.JMenuItem mAction1MI;
  private javax.swing.JMenuItem mAction2MI;
  private javax.swing.JMenuItem mAction3MI;
  private javax.swing.JMenuItem mAction4MI;
  private javax.swing.JMenu mControl;
  private javax.swing.JMenuItem mStartCtrlMI;
  private javax.swing.JMenuItem mStopCtrlMI;
  private javax.swing.JMenuItem mResetCtrMI;
  // End of variables declaration//GEN-END:variables
}
