/*
 * Weibull_n.java
 *
 * Created on February 1, 2008, 3:52 PM
 */

package usda.weru.erosion.gui;

import java.awt.event.ActionListener;
import java.awt.event.FocusListener;
import java.awt.event.WindowListener;

/**
 *
 * @author  wjr
 */
public class Weibull_n extends javax.swing.JDialog implements ActionListener, FocusListener, WindowListener {
    private static final long serialVersionUID = 1L;
    
    /** Creates new form Weibull_n
	 * @param parent
	 * @param modal */
    public Weibull_n(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.
     */
    // suppression is because the Netbeans designer doesn't allow specifying the type of
    // DefaultComboBoxModels.
    @SuppressWarnings({"rawtypes","unchecked"})
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel37 = new javax.swing.JLabel();
        JTF_calmFraction = new javax.swing.JTextField();
        jLabel38 = new javax.swing.JLabel();
        jLabel39 = new javax.swing.JLabel();
        JTF_weibullK = new javax.swing.JTextField();
        JTF_weibullC = new javax.swing.JTextField();
        JB_OK = new javax.swing.JButton();
        JB_Cancel = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        JCB_intervals = new javax.swing.JComboBox<String>();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Weibull Parameters");
        setModal(true);
        addWindowListener(this);

        jLabel37.setText("Fraction of time winds are calm (hr/hr)");

        JTF_calmFraction.setText("0.0");
        JTF_calmFraction.setToolTipText("Weather:calm");
        JTF_calmFraction.setName("WeaCalmWind"); // NOI18N
        JTF_calmFraction.addActionListener(this);
        JTF_calmFraction.addFocusListener(this);

        jLabel38.setText("Weibull \"c\" factor (m/s)");

        jLabel39.setText("Weibull \"k\" factor");

        JTF_weibullK.setText("0.0");
        JTF_weibullK.setToolTipText("Weather:weibullK");
        JTF_weibullK.setName("WeaWeibullK"); // NOI18N
        JTF_weibullK.addActionListener(this);
        JTF_weibullK.addFocusListener(this);

        JTF_weibullC.setText("0.0");
        JTF_weibullC.setToolTipText("Weather:weibullC");
        JTF_weibullC.setName("WeaWeibullC"); // NOI18N
        JTF_weibullC.addActionListener(this);
        JTF_weibullC.addFocusListener(this);

        JB_OK.setText("Calculate and return");
        JB_OK.addActionListener(this);

        JB_Cancel.setText("Cancel");
        JB_Cancel.addActionListener(this);

        jLabel1.setText("Enter Weibull parameters and calculate wind speed table");

        jLabel32.setText("Number of interval / day to run EROSION");

        JCB_intervals.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1 Hour (24 intervals)", "30 Minutes (48 intervals)", "20 Minutes (72 intervals)", "15 Minutes (96 intervals)", "10 Minutes (144 intervals)", "5 Minutes (288 intervals)" }));
        JCB_intervals.addActionListener(this);

        jLabel2.setText("Use of Weibull parameters is optional. Enter actual data on main screen if you have it.");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(29, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel32, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(JCB_intervals, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel37, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(10, 10, 10)
                            .addComponent(JTF_calmFraction, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel38, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(10, 10, 10)
                            .addComponent(JTF_weibullC, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel39, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(10, 10, 10)
                            .addComponent(JTF_weibullK, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(44, 44, 44)
                            .addComponent(JB_OK)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(JB_Cancel)
                            .addGap(2, 2, 2))))
                .addGap(22, 22, 22))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(19, 19, 19)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel37)
                    .addComponent(JTF_calmFraction, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel38)
                    .addComponent(JTF_weibullC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel39)
                    .addComponent(JTF_weibullK, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel32)
                    .addComponent(JCB_intervals, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JB_OK)
                    .addComponent(JB_Cancel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }

    // Code for dispatching events from components to event handlers.

    public void actionPerformed(java.awt.event.ActionEvent evt) {
        if (evt.getSource() == JTF_calmFraction) {
            Weibull_n.this.JTF_calmFractionActionPerformed(evt);
        }
        else if (evt.getSource() == JTF_weibullK) {
            Weibull_n.this.JTF_weibullKActionPerformed(evt);
        }
        else if (evt.getSource() == JTF_weibullC) {
            Weibull_n.this.JTF_weibullCActionPerformed(evt);
        }
        else if (evt.getSource() == JB_OK) {
            Weibull_n.this.JB_OKActionPerformed(evt);
        }
        else if (evt.getSource() == JB_Cancel) {
            Weibull_n.this.JB_CancelActionPerformed(evt);
        }
        else if (evt.getSource() == JCB_intervals) {
            Weibull_n.this.JCB_intervalsActionPerformed(evt);
        }
    }

    public void focusGained(java.awt.event.FocusEvent evt) {
        if (evt.getSource() == JTF_calmFraction) {
            Weibull_n.this.JTF_calmFractionFocusGained(evt);
        }
        else if (evt.getSource() == JTF_weibullK) {
            Weibull_n.this.JTF_weibullKFocusGained(evt);
        }
        else if (evt.getSource() == JTF_weibullC) {
            Weibull_n.this.JTF_weibullCFocusGained(evt);
        }
    }

    public void focusLost(java.awt.event.FocusEvent evt) {
        if (evt.getSource() == JTF_calmFraction) {
            Weibull_n.this.JTF_calmFractionFocusLost(evt);
        }
        else if (evt.getSource() == JTF_weibullK) {
            Weibull_n.this.JTF_weibullKFocusLost(evt);
        }
        else if (evt.getSource() == JTF_weibullC) {
            Weibull_n.this.JTF_weibullCFocusLost(evt);
        }
    }

    public void windowActivated(java.awt.event.WindowEvent evt) {
    }

    public void windowClosed(java.awt.event.WindowEvent evt) {
    }

    public void windowClosing(java.awt.event.WindowEvent evt) {
        if (evt.getSource() == Weibull_n.this) {
            Weibull_n.this.formWindowClosing(evt);
        }
    }

    public void windowDeactivated(java.awt.event.WindowEvent evt) {
    }

    public void windowDeiconified(java.awt.event.WindowEvent evt) {
    }

    public void windowIconified(java.awt.event.WindowEvent evt) {
    }

    public void windowOpened(java.awt.event.WindowEvent evt) {
    }// </editor-fold>//GEN-END:initComponents

    protected void JTF_calmFractionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JTF_calmFractionActionPerformed
    }//GEN-LAST:event_JTF_calmFractionActionPerformed

    protected void JTF_calmFractionFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_JTF_calmFractionFocusLost
            }//GEN-LAST:event_JTF_calmFractionFocusLost

    protected void JTF_weibullKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JTF_weibullKActionPerformed
            }//GEN-LAST:event_JTF_weibullKActionPerformed

    protected void JTF_weibullKFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_JTF_weibullKFocusLost
            }//GEN-LAST:event_JTF_weibullKFocusLost

    protected void JTF_weibullCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JTF_weibullCActionPerformed
            }//GEN-LAST:event_JTF_weibullCActionPerformed

    protected void JTF_weibullCFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_JTF_weibullCFocusLost
            }//GEN-LAST:event_JTF_weibullCFocusLost

    protected void JCB_intervalsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JCB_intervalsActionPerformed
            }//GEN-LAST:event_JCB_intervalsActionPerformed

    protected void JB_OKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_OKActionPerformed
        }//GEN-LAST:event_JB_OKActionPerformed

    protected void JB_CancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JB_CancelActionPerformed
        }//GEN-LAST:event_JB_CancelActionPerformed

    protected void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
            }//GEN-LAST:event_formWindowClosing

    protected void JTF_calmFractionFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_JTF_calmFractionFocusGained
            }//GEN-LAST:event_JTF_calmFractionFocusGained

    protected void JTF_weibullCFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_JTF_weibullCFocusGained
            }//GEN-LAST:event_JTF_weibullCFocusGained

    protected void JTF_weibullKFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_JTF_weibullKFocusGained
            }//GEN-LAST:event_JTF_weibullKFocusGained
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                Weibull_n dialog = new Weibull_n(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton JB_Cancel;
    public javax.swing.JButton JB_OK;
    public javax.swing.JComboBox<String> JCB_intervals;
    public javax.swing.JTextField JTF_calmFraction;
    public javax.swing.JTextField JTF_weibullC;
    public javax.swing.JTextField JTF_weibullK;
    public javax.swing.JLabel jLabel1;
    public javax.swing.JLabel jLabel2;
    public javax.swing.JLabel jLabel32;
    public javax.swing.JLabel jLabel37;
    public javax.swing.JLabel jLabel38;
    public javax.swing.JLabel jLabel39;
    // End of variables declaration//GEN-END:variables
    
}
