// ==========================================================================
// $Id: AktionPopupWindow.java,v 1.1 2002/09/15 15:02:31 hitoshi Exp $
// popup window action
// ==========================================================================
// 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.1 $
// $Date: 2002/09/15 15:02:31 $
// $Author: hitoshi $
// ==========================================================================
package de.mpg.mpisb.timerclock;

/**
 * AktionPopupWindow
 * @author Yamauchi Hitoshi
 */
public class AktionPopupWindow extends javax.swing.JDialog {

    /** Creates new form JDialog */
    public AktionPopupWindow(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        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
        jPanel1 = new javax.swing.JPanel();
        mOkBtn = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        mShowTimeTF = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        mShowMessageTF = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        
        setTitle("Timer Clock : AktionPopup");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });
        
        jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
        
        mOkBtn.setText("OK");
        mOkBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mOkBtnActionPerformed(evt);
            }
        });
        
        jPanel1.add(mOkBtn);
        
        getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);
        
        jPanel2.setLayout(new java.awt.GridBagLayout());
        java.awt.GridBagConstraints gridBagConstraints1;
        
        jPanel2.setBorder(new javax.swing.border.TitledBorder("popup message"));
        mShowTimeTF.setEditable(false);
        gridBagConstraints1 = new java.awt.GridBagConstraints();
        gridBagConstraints1.gridx = 1;
        gridBagConstraints1.gridy = 1;
        gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints1.insets = new java.awt.Insets(0, 6, 0, 6);
        gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
        jPanel2.add(mShowTimeTF, gridBagConstraints1);
        
        jLabel1.setFont(new java.awt.Font("Dialog", 1, 24));
        jLabel1.setText("Timer Clock: ALARM !");
        gridBagConstraints1 = new java.awt.GridBagConstraints();
        gridBagConstraints1.gridwidth = 2;
        gridBagConstraints1.insets = new java.awt.Insets(10, 10, 10, 10);
        jPanel2.add(jLabel1, gridBagConstraints1);
        
        mShowMessageTF.setEditable(false);
        gridBagConstraints1 = new java.awt.GridBagConstraints();
        gridBagConstraints1.gridx = 0;
        gridBagConstraints1.gridy = 2;
        gridBagConstraints1.gridwidth = 2;
        gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints1.insets = new java.awt.Insets(5, 5, 5, 5);
        gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
        jPanel2.add(mShowMessageTF, gridBagConstraints1);
        
        jLabel2.setText("at :");
        gridBagConstraints1 = new java.awt.GridBagConstraints();
        gridBagConstraints1.gridx = 0;
        gridBagConstraints1.gridy = 1;
        gridBagConstraints1.insets = new java.awt.Insets(12, 5, 12, 5);
        gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST;
        jPanel2.add(jLabel2, gridBagConstraints1);
        
        getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);
        
        pack();
    }//GEN-END:initComponents

    private void mOkBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mOkBtnActionPerformed
      // Add your handling code here:
      this.setVisible(false);
    }//GEN-LAST:event_mOkBtnActionPerformed

    /** Closes the dialog */
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        setVisible(false);
        dispose();
    }//GEN-LAST:event_closeDialog

  /**
   * set messages
   */
  public void setMessage(String timestr, String messageStr)
  {
    this.mShowTimeTF.setText(timestr);
    this.mShowMessageTF.setText(messageStr);
  }
  /**
   * popup
   */
  public void popup(boolean ismodal)
  {
    this.setModal(ismodal);
    this.show();
  }

  /**
   * @param args the command line arguments
   */
  public static void main(String args[]) 
  {
    AktionPopupWindow jd = new AktionPopupWindow(new javax.swing.JFrame(), true);
    jd.setMessage("00:20", "Here comes the sun!");
    boolean modal = true;
    jd.popup(modal);
  }

  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JPanel jPanel1;
  private javax.swing.JButton mOkBtn;
  private javax.swing.JPanel jPanel2;
  private javax.swing.JTextField mShowTimeTF;
  private javax.swing.JLabel jLabel1;
  private javax.swing.JTextField mShowMessageTF;
  private javax.swing.JLabel jLabel2;
  // End of variables declaration//GEN-END:variables

}
