/*
 * HyTest2PopMeanDialog.java
 *
 * Created on June 11, 2008, 11:04 AM
 */

package org.statcato.dialogs.stat.hytest;

import org.statcato.*;
import org.statcato.spreadsheet.*;
import org.statcato.statistics.inferential.*;
import org.statcato.utils.HelperFunctions;
import java.util.*;
import javax.swing.*;
import org.statcato.statistics.BasicStatistics;

/**
 * A dialog for claims about the difference of two population means 
 * from two independent samples.
 * Allows the user to specify data samples in columns of a Datasheet,
 * or provide summary data values.  The user must also provide
 * the confidence level, alternative hypothesis, hypothesized 
 * mean difference, population standard deviations (if known), and
 * whether the population variances are assumed equal.
 * Computes and displays in log window the significance level, 
 * critical value, test statistic, and p-Value.
 * 
 * @author  Margaret Yau
 * @version %I%, %G%
 * @see org.statcato.statistics.inferential.HypothesisTest2MeanSigmaUnknown
 * @see org.statcato.statistics.inferential.HypothesisTest2MeanSigmaKnown
 * @since 1.0
 */
public class HyTest2PopMeanDialog extends StatcatoDialog {

    /** Creates new form HyTest2PopMeanDialog */
    public HyTest2PopMeanDialog(java.awt.Frame parent, boolean modal,
            Statcato mTab) {
        super(parent, modal);
        initComponents();
        
        app = mTab;
        ParentSpreadsheet = app.getSpreadsheet(); 
        
        ButtonGroup group1 = new ButtonGroup();
        group1.add(Sample1ColRadioButton);
        group1.add(Sample2ColRadioButton);
        group1.add(SummaryRadioButton);
        
        ButtonGroup group3 = new ButtonGroup();
        group3.add(SigRadioButton);
        group3.add(ConfRadioButton);
        
        ParentSpreadsheet.populateComboBox(LabelsComboBox);
        ParentSpreadsheet.populateComboBox(ValuesComboBox);
        ParentSpreadsheet.populateComboBox(Pop1ComboBox);
        ParentSpreadsheet.populateComboBox(Pop2ComboBox);
        
        getRootPane().setDefaultButton(OKButton);
        setHelpFile("stat-hytest-2mean");
        name = "Hypothesis Test: 2-Population Means";
        description = "For performing calculations for testing claims " +
                "about the difference of two population means from " +
                "two independent samples. ";
        helpStrings.add("The sample data can be provided in one of three ways...");
        helpStrings.add("Samples in one column: The population labels of " +
                "samples are in one column of the Datasheet, " +
                "and the individual samples are in another column.");
        helpStrings.add("Samples in two columns: The samples of the two " +
                "population are in two separate columns.");
        helpStrings.add("Summarized sample data: The sample size, " +
                "mean, and standard deviation of each of the two " +
                "populations are provided.");
        helpStrings.add("If population standard deviations are known, " +
                "check the appropriate check box and provide the standard deviations.");
        helpStrings.add("Check the Assume population variances are equal " +
                "check box if the population variances are assumed equal.");
        helpStrings.add("Specify the signficance or confidence level.");
        helpStrings.add("Select the form of alternative hypothesis " +
                "and enter the Hypothesized Mean in the provided text box.");

    }

    /**
     * Updates elements on the dialog so that they have the most
     * current values.  Called by {@link #setVisible} to make
     * sure the dialog displays current values when made visible again.
     * 
     * @see #setVisible(boolean)
     */
    @Override
    public void updateElements() {
        updateComboBox(LabelsComboBox);
        updateComboBox(ValuesComboBox);
        updateComboBox(Pop1ComboBox);
        updateComboBox(Pop2ComboBox);
    }
    
    /** 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.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        OKButton = new javax.swing.JButton();
        CancelButton = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        Sample2ColRadioButton = new javax.swing.JRadioButton();
        n2TextField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        Pop2ComboBox = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        stdev1TextField = new javax.swing.JTextField();
        stdev2TextField = new javax.swing.JTextField();
        SummaryRadioButton = new javax.swing.JRadioButton();
        n1TextField = new javax.swing.JTextField();
        LabelsComboBox = new javax.swing.JComboBox();
        Pop1ComboBox = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        mean2TextField = new javax.swing.JTextField();
        Sample1ColRadioButton = new javax.swing.JRadioButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        ValuesComboBox = new javax.swing.JComboBox();
        mean1TextField = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        Sigma2TextField = new javax.swing.JTextField();
        Sigma1TextField = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        VarEqualCheckBox = new javax.swing.JCheckBox();
        SigmaKnownCheckBox = new javax.swing.JCheckBox();
        jPanel3 = new javax.swing.JPanel();
        HyTextField = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        AltComboBox = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        SigPanel = new javax.swing.JPanel();
        SigLabel = new javax.swing.JLabel();
        ConfidenceTextField = new javax.swing.JTextField();
        ConfRadioButton = new javax.swing.JRadioButton();
        SigRadioButton = new javax.swing.JRadioButton();
        SigTextField = new javax.swing.JTextField();
        ConfLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Hypothesis Test: 2-Population Means");

        OKButton.setText("OK");
        OKButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OKButtonActionPerformed(evt);
            }
        });

        CancelButton.setText("Cancel");
        CancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelButtonActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Inputs"));

        jLabel1.setText("Labels in column:");

        Sample2ColRadioButton.setText("Samples in two columns");
        Sample2ColRadioButton.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                Sample2ColRadioButtonStateChanged(evt);
            }
        });

        n2TextField.setEnabled(false);

        jLabel5.setText("Population 1:");

        Pop2ComboBox.setEnabled(false);

        jLabel8.setText("Mean");

        stdev1TextField.setEnabled(false);

        stdev2TextField.setEnabled(false);

        SummaryRadioButton.setText("Summarized sample data");
        SummaryRadioButton.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                SummaryRadioButtonStateChanged(evt);
            }
        });

        n1TextField.setEnabled(false);

        Pop1ComboBox.setEnabled(false);

        jLabel4.setText("Population 2:");

        jLabel6.setText("Population 2:");

        jLabel7.setText("Sample Size");

        mean2TextField.setEnabled(false);

        Sample1ColRadioButton.setSelected(true);
        Sample1ColRadioButton.setText("Samples in one column");
        Sample1ColRadioButton.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                Sample1ColRadioButtonStateChanged(evt);
            }
        });

        jLabel2.setText("Values in column:");

        jLabel9.setText("Standard Deviation");

        jLabel3.setText("Population 1:");

        mean1TextField.setEnabled(false);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel5))
                        .addGap(35, 35, 35)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(n1TextField, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(n2TextField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(mean2TextField, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(stdev2TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(mean1TextField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel9)
                                    .addComponent(stdev1TextField, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(254, 254, 254))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(SummaryRadioButton)
                            .addComponent(Sample1ColRadioButton)
                            .addComponent(Sample2ColRadioButton)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(21, 21, 21)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel1)
                                            .addComponent(jLabel2))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(ValuesComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(LabelsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel4)
                                            .addComponent(jLabel3))
                                        .addGap(26, 26, 26)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(Pop2ComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(Pop1ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 137, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {n1TextField, n2TextField});

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {mean1TextField, mean2TextField});

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {stdev1TextField, stdev2TextField});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Sample1ColRadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(LabelsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(ValuesComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(23, 23, 23)
                .addComponent(Sample2ColRadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(Pop1ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Pop2ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(SummaryRadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9))
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(n1TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mean1TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(stdev1TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(n2TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mean2TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(stdev2TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(41, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Population Standard Deviations/Variances"));

        Sigma2TextField.setEnabled(false);

        Sigma1TextField.setEnabled(false);

        jLabel10.setText("<html>&sigma;<sub>1</sub>:</html>");

        jLabel11.setText("<html>&sigma;<sub>2</sub>:</html>");

        VarEqualCheckBox.setText("Assume population variances are equal");

        SigmaKnownCheckBox.setText("Population standard deviations known");
        SigmaKnownCheckBox.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                SigmaKnownCheckBoxStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(VarEqualCheckBox)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(Sigma1TextField, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(Sigma2TextField))))
                    .addComponent(SigmaKnownCheckBox))
                .addContainerGap(91, Short.MAX_VALUE))
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {Sigma1TextField, Sigma2TextField});

        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(SigmaKnownCheckBox)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(Sigma1TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(Sigma2TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(13, 13, 13)
                .addComponent(VarEqualCheckBox)
                .addContainerGap(7, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Alternative Hypothesis"));

        HyTextField.setText("0");

        jLabel15.setText("Hypothesized Mean Difference:");

        AltComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Less than", "Not Equal to", "Greater than" }));
        AltComboBox.setSelectedIndex(1);

        jLabel14.setText("Alternative Hypothesis:");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(HyTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(AltComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(51, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(AltComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel15)
                    .addComponent(HyTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        SigPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Significance"));

        SigLabel.setText("0 - 1.00 (e.g. 0.05)");

        ConfidenceTextField.setText("0.95");
        ConfidenceTextField.setEnabled(false);
        ConfidenceTextField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                ConfidenceTextFieldFocusLost(evt);
            }
        });

        ConfRadioButton.setText("Confidence Level:");
        ConfRadioButton.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                ConfRadioButtonStateChanged(evt);
            }
        });

        SigRadioButton.setSelected(true);
        SigRadioButton.setText("Significance Level:");
        SigRadioButton.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                SigRadioButtonStateChanged(evt);
            }
        });

        SigTextField.setText("0.05");
        SigTextField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                SigTextFieldFocusLost(evt);
            }
        });

        ConfLabel.setText("0 - 1.00 (e.g. 0.95)");
        ConfLabel.setEnabled(false);

        javax.swing.GroupLayout SigPanelLayout = new javax.swing.GroupLayout(SigPanel);
        SigPanel.setLayout(SigPanelLayout);
        SigPanelLayout.setHorizontalGroup(
            SigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SigPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(SigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ConfRadioButton)
                    .addComponent(SigRadioButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(SigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(SigTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ConfidenceTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(SigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ConfLabel)
                    .addComponent(SigLabel))
                .addContainerGap())
        );

        SigPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {ConfidenceTextField, SigTextField});

        SigPanelLayout.setVerticalGroup(
            SigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SigPanelLayout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(SigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(SigRadioButton)
                    .addComponent(SigTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(SigLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(SigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ConfRadioButton)
                    .addComponent(ConfidenceTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ConfLabel))
                .addContainerGap(21, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 387, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(SigPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(283, 283, 283)
                        .addComponent(OKButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(CancelButton)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {CancelButton, OKButton});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(1, 1, 1)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(SigPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CancelButton)
                    .addComponent(OKButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void SummaryRadioButtonStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_SummaryRadioButtonStateChanged
        if (SummaryRadioButton.isSelected()) {
            n1TextField.setEnabled(true);
            n2TextField.setEnabled(true);
            mean1TextField.setEnabled(true);
            mean2TextField.setEnabled(true);
            if (SigmaKnownCheckBox.isSelected()) {
                stdev1TextField.setEnabled(false);
                stdev2TextField.setEnabled(false);
            } else {
                stdev1TextField.setEnabled(true);
                stdev2TextField.setEnabled(true);
            }
        } else {
            n1TextField.setEnabled(false);
            n2TextField.setEnabled(false);
            mean1TextField.setEnabled(false);
            mean2TextField.setEnabled(false);
            stdev1TextField.setEnabled(false);
            stdev2TextField.setEnabled(false);
        }
    }//GEN-LAST:event_SummaryRadioButtonStateChanged

    private void Sample1ColRadioButtonStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_Sample1ColRadioButtonStateChanged
        if (Sample1ColRadioButton.isSelected()) {
            LabelsComboBox.setEnabled(true);
            ValuesComboBox.setEnabled(true);
        } else {
            LabelsComboBox.setEnabled(false);
            ValuesComboBox.setEnabled(false);
        }
    }//GEN-LAST:event_Sample1ColRadioButtonStateChanged

    private void Sample2ColRadioButtonStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_Sample2ColRadioButtonStateChanged
        if (Sample2ColRadioButton.isSelected()) {
            Pop1ComboBox.setEnabled(true);
            Pop2ComboBox.setEnabled(true);
        } else {
            Pop1ComboBox.setEnabled(false);
            Pop2ComboBox.setEnabled(false);
        }
    }//GEN-LAST:event_Sample2ColRadioButtonStateChanged

    @SuppressWarnings("unchecked")
    private void OKButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OKButtonActionPerformed
        app.compoundEdit = new DialogEdit("hypothesis test 2 mean");
        
        int n1 = 0, n2 = 0;   // sample sizes
        double xBar1 = 0, xBar2 = 0;    // sample means
        double stdev1 = 0, stdev2 = 0;  // sample standard deviations
        double confidenceLevel;
        
        String heading = "Hypothesis Test - Two population means:";
        String text = "";
        
        if (ConfRadioButton.isSelected()) {
            // get confidence level from dialog
            try {
                confidenceLevel = Double.parseDouble(ConfidenceTextField.getText());
            } catch (NumberFormatException e) {
                app.showErrorDialog("Enter a number between 0 and 1 for the confidence level.");
                return;
            }
            if (confidenceLevel <= 0 || confidenceLevel >= 1) {
                app.showErrorDialog("Enter a number between 0 and 1 for the confidence level.");
                return;
            }
        }
        else {
            // get confidence level from dialog
            try {
                confidenceLevel = 1 - Double.parseDouble(SigTextField.getText());
            } catch (NumberFormatException e) {
                app.showErrorDialog("Enter a number between 0 and 1 for the significance level.");
                return;
            }
            if (confidenceLevel <= 0 || confidenceLevel >= 1) {
                app.showErrorDialog("Enter a number between 0 and 1 for the significance level.");
                return;
            }
        }
        heading += "  confidence level = " + 
                String.format("%."+
                HelperFunctions.getNumDecimalPlaces(ConfidenceTextField.getText())+"f", 
                confidenceLevel);
        
        // summary values
        if (SummaryRadioButton.isSelected()) {
            try {
                n1 = Integer.parseInt(n1TextField.getText());
                n2 = Integer.parseInt(n2TextField.getText());
            } catch (NumberFormatException e) {
                app.showErrorDialog("Enter an integer for the sample sizes.");
                return;
            }
            try {
                xBar1 = Double.parseDouble(mean1TextField.getText());
                xBar2 = Double.parseDouble(mean2TextField.getText());
            } catch (NumberFormatException e) {
                app.showErrorDialog("Enter valid sample means.");
                return;
            }
            if (!SigmaKnownCheckBox.isSelected()) {
                try {
                    stdev1 = Double.parseDouble(stdev1TextField.getText());
                    stdev2 = Double.parseDouble(stdev2TextField.getText());
                } catch (NumberFormatException e) {
                    app.showErrorDialog("Enter valid sample standard deviations.");
                    return;
                }
            }
        } else {
            Vector<Cell> Vector1 = null, Vector2 = null;
            Vector<Double> InputVector1 = null, InputVector2 = null;
            
            // sample values in one column, labels in another
            if (Sample1ColRadioButton.isSelected()) {
                // get data for the labels column
                String columnLabel = LabelsComboBox.getSelectedItem().toString();
                text += "Population labels in " + columnLabel + "<br>";
                if (columnLabel.equals("")) { // no labels column
                    app.showErrorDialog("Select the column containing category labels.");
                    return;
                }
                int column = ParentSpreadsheet.parseColumnNumber(columnLabel);
                Vector<Cell> LabelsVector = ParentSpreadsheet.getColumn(column);
                
                //get data for the sample values column
                columnLabel = ValuesComboBox.getSelectedItem().toString();
                text += "Samples values in " + columnLabel + "<br>";
                if (columnLabel.equals("")) {   // no values column
                    app.showErrorDialog("Select the column containing sample values.");
                    return;
                }
                column = ParentSpreadsheet.parseColumnNumber(columnLabel);
                Vector<Cell> ValuesVector = ParentSpreadsheet.getColumn(column);
                
                // split values into two vectors corresponding to the two categories
                try {
                    Object returnValues[] =
                            HelperFunctions.splitValuesVectorByLabels(LabelsVector, ValuesVector);
                    
                    text += "Population 1 = " + returnValues[0] + "<br>";
                    text += "Population 2 = " + returnValues[2] + "<br>";
                    
                    Vector1 = (Vector<Cell>) returnValues[1];
                    Vector2 = (Vector<Cell>) returnValues[3];
                    
                    InputVector1 =
                            HelperFunctions.ConvertInputVectorToDoubles(Vector1);
                    if (InputVector1 == null) {
                        app.showErrorDialog("Invalid input column " + returnValues[0] +
                                ": all data must be numbers.");
                        return;
                    }
                    InputVector2 =
                            HelperFunctions.ConvertInputVectorToDoubles(Vector2);
                    if (InputVector2 == null) {
                        app.showErrorDialog("Invalid input column " + returnValues[2] +
                                ": all data must be numbers.");
                        return;
                    }
                } catch (Exception e) {
                    app.showErrorDialog(e.getMessage());
                    return;
                }
            }
            // sample values of two populations in separate columns
            else if (Sample2ColRadioButton.isSelected()) {
                //get data for the two columns of sample values
                String columnLabel = Pop1ComboBox.getSelectedItem().toString();
                text += "Samples of population 1 in " + columnLabel + "<br>";
                if (columnLabel.equals("")) {   // no values column
                    app.showErrorDialog("Select the column containing sample " +
                            "values for the first population.");
                    return;
                }
                int column = ParentSpreadsheet.parseColumnNumber(columnLabel);
                Vector1 = ParentSpreadsheet.getColumn(column);
                InputVector1 =
                        HelperFunctions.ConvertInputVectorToDoubles(Vector1);
                if (InputVector1 == null) {
                    app.showErrorDialog("Invalid input column " + columnLabel +
                            ": all data must be numbers.");
                    return;
                }
                
                columnLabel = Pop2ComboBox.getSelectedItem().toString();
                text += "Samples of population 2 in " + columnLabel + "<br>";
                if (columnLabel.equals("")) {   // no values column
                    app.showErrorDialog("Select the column containing sample " +
                            "values for the second population.");
                    return;
                }
                column = ParentSpreadsheet.parseColumnNumber(columnLabel);
                Vector2 = ParentSpreadsheet.getColumn(column);
                InputVector2 =
                        HelperFunctions.ConvertInputVectorToDoubles(Vector2);
                if (InputVector2 == null) {
                    app.showErrorDialog("Invalid input column " + columnLabel +
                            ": all data must be numbers.");
                    return;
                }
            }
            
            // compute statistics of input vectors
            n1 = BasicStatistics.Nnonmissing(InputVector1);
            xBar1 = BasicStatistics.mean(InputVector1).doubleValue();
            stdev1 = BasicStatistics.stdev(InputVector1).doubleValue();
            n2 = BasicStatistics.Nnonmissing(InputVector2);
            xBar2 = BasicStatistics.mean(InputVector2).doubleValue();
            stdev2 = BasicStatistics.stdev(InputVector2).doubleValue();
        }
        
        text += "<br><table border='1'>";
        text += "<tr><td>&nbsp;</td><td>N</td><td>Mean</td>";
        if (!SigmaKnownCheckBox.isSelected())
            text += "<td>Stdev</td>";
        text += "</tr>";
        text += "<tr><td>Population 1</td><td>" + n1 + "</td><td>" +
                HelperFunctions.formatFloat(xBar1, 3) + "</td>";
        if (!SigmaKnownCheckBox.isSelected())
            text += "<td>" + HelperFunctions.formatFloat(stdev1, 3) + "</td>";
        text += "</tr>";
        text += "<tr><td>Population 2</td><td>" + n2 + "</td><td>" +
                HelperFunctions.formatFloat(xBar2, 3) + "</td>";
        if (!SigmaKnownCheckBox.isSelected())
            text += "<td>" + HelperFunctions.formatFloat(stdev2, 3) + "</td>";
        text += "</tr></table><br>";
        

        // get hypothesized difference 
        double diff = 0;
        try {
            diff = Double.parseDouble(HyTextField.getText());
        }
        catch (NumberFormatException e) {
            app.showErrorDialog("Enter a valid hypothesized difference.");
            return;
        }
        
        // get type of test
        int typeTest = AltComboBox.getSelectedIndex();
        text += "Null hypothesis: &mu;<sub>1</sub> - &mu;<sub>2</sub> = " + 
                diff + "<br>";
        text += "Alternative hypothesis: &mu;<sub>1</sub> - &mu;<sub>2</sub> ";
        if (typeTest == HypothesisTest.LEFT_TAIL)
            text += "&lt;";
        else if (typeTest == HypothesisTest.RIGHT_TAIL)
            text += "&gt;";
        else
            text += "&ne;";
        text += diff + " <br>";
        
        if (VarEqualCheckBox.isSelected()) {
            text += "* Population variances are assumed equal. *<br>";
        }
        
        if (SigmaKnownCheckBox.isSelected()) {
            double sigma1 = 0, sigma2 = 0;
            
            try  {
                sigma1 = Double.parseDouble(Sigma1TextField.getText());
                sigma2 = Double.parseDouble(Sigma2TextField.getText());
                text += "* Population standard deviations are known. *<br>";
                text += "  &sigma<sub>1</sub> = " + sigma1 + 
                        ", &sigma<sub>2</sub> = " + sigma2;
                HypothesisTest2MeanSigmaKnown ht = new 
                        HypothesisTest2MeanSigmaKnown(n1, n2, xBar1, xBar2, 
                        sigma1, sigma2, diff, confidenceLevel, typeTest);
                text += "<br><table border='1'>";
                text += "<tr><td>Significance Level</td></td><td>Critical Value</td>" +
                        "<td>Test Statistic Z</td>" + "<td>p-Value</td></tr>";
                text += "<tr><td>" +
                        HelperFunctions.formatFloat(1-confidenceLevel, 2)  +
                        "</td><td>" + ht.criticalValue()
                        + "</td><td>" + HelperFunctions.formatFloat(ht.testStatistics(), 3)
                        + "</td><td>" + HelperFunctions.formatFloat(ht.pValue(), 4)
                        + "</td></tr></table>";                
            } catch (NumberFormatException e) {
                app.showErrorDialog("Enter valid population standard deviations.");
                return;
            }
        } else {
            text += "* Population standard deviations are unknown. *<br>";
            HypothesisTest2MeanSigmaUnknown ht = new
                    HypothesisTest2MeanSigmaUnknown(n1, n2, xBar1, xBar2,
                    stdev1, stdev2, diff, confidenceLevel, typeTest,
                    VarEqualCheckBox.isSelected());
            text += "DOF = " + ht.DOF();
            text += "<br><table border='1'>";
                text += "<tr><td>Significance Level</td></td><td>Critical Value</td>" +
                        "<td>Test Statistic t</td>" + "<td>p-Value</td></tr>";
                text += "<tr><td>" +
                        HelperFunctions.formatFloat(1-confidenceLevel, 2)  +
                        "</td><td>" + ht.criticalValue()
                        + "</td><td>" + HelperFunctions.formatFloat(ht.testStatistics(), 3)
                        + "</td><td>" + HelperFunctions.formatFloat(ht.pValue(), 4)
                        + "</td></tr></table>";
        }
        
        app.addLogParagraph(heading, text);

        app.compoundEdit.end();
        app.addCompoundEdit(app.compoundEdit);
        
        setVisible(false);
    }//GEN-LAST:event_OKButtonActionPerformed

    private void CancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelButtonActionPerformed
        setVisible(false);
    }//GEN-LAST:event_CancelButtonActionPerformed

    private void SigmaKnownCheckBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_SigmaKnownCheckBoxStateChanged
        if (SigmaKnownCheckBox.isSelected()) {
            if (SummaryRadioButton.isSelected()) {
                stdev1TextField.setEnabled(false);
                stdev2TextField.setEnabled(false);
            }
            Sigma1TextField.setEnabled(true);
            Sigma2TextField.setEnabled(true);
            VarEqualCheckBox.setEnabled(false);
        } else {
            if (SummaryRadioButton.isSelected()) {
                stdev1TextField.setEnabled(true);
                stdev2TextField.setEnabled(true);
            }
            Sigma1TextField.setEnabled(false);
            Sigma2TextField.setEnabled(false);
            VarEqualCheckBox.setEnabled(true);
        }
    }//GEN-LAST:event_SigmaKnownCheckBoxStateChanged

    private void ConfidenceTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_ConfidenceTextFieldFocusLost
        try {
            String confString = ConfidenceTextField.getText();
            double conf = Double.parseDouble(confString);
            double sig = 1.0 - conf;
            SigTextField.setText(
                    String.format("%."+HelperFunctions.getNumDecimalPlaces(confString)+"f", sig));
        } catch (NumberFormatException e) {
        }
    }//GEN-LAST:event_ConfidenceTextFieldFocusLost

    private void ConfRadioButtonStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_ConfRadioButtonStateChanged
        if (ConfRadioButton.isSelected()) {
            ConfidenceTextField.setEnabled(true);
            ConfLabel.setEnabled(true);
        } else {
            ConfidenceTextField.setEnabled(false);
            ConfLabel.setEnabled(false);
        }
    }//GEN-LAST:event_ConfRadioButtonStateChanged

    private void SigRadioButtonStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_SigRadioButtonStateChanged
        if (SigRadioButton.isSelected()) {
            SigTextField.setEnabled(true);
            SigLabel.setEnabled(true);
        } else {
            SigTextField.setEnabled(false);
            SigLabel.setEnabled(false);
        }
    }//GEN-LAST:event_SigRadioButtonStateChanged

    private void SigTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_SigTextFieldFocusLost
        try {
            String sigString = SigTextField.getText();
            double sig = Double.parseDouble(sigString);
            double conf = 1 - sig;
            ConfidenceTextField.setText(
                    String.format("%."+HelperFunctions.getNumDecimalPlaces(sigString)+"f", conf));
        } catch (NumberFormatException e) {
        }
    }//GEN-LAST:event_SigTextFieldFocusLost

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox AltComboBox;
    private javax.swing.JButton CancelButton;
    private javax.swing.JLabel ConfLabel;
    private javax.swing.JRadioButton ConfRadioButton;
    private javax.swing.JTextField ConfidenceTextField;
    private javax.swing.JTextField HyTextField;
    private javax.swing.JComboBox LabelsComboBox;
    private javax.swing.JButton OKButton;
    private javax.swing.JComboBox Pop1ComboBox;
    private javax.swing.JComboBox Pop2ComboBox;
    private javax.swing.JRadioButton Sample1ColRadioButton;
    private javax.swing.JRadioButton Sample2ColRadioButton;
    private javax.swing.JLabel SigLabel;
    private javax.swing.JPanel SigPanel;
    private javax.swing.JRadioButton SigRadioButton;
    private javax.swing.JTextField SigTextField;
    private javax.swing.JTextField Sigma1TextField;
    private javax.swing.JTextField Sigma2TextField;
    private javax.swing.JCheckBox SigmaKnownCheckBox;
    private javax.swing.JRadioButton SummaryRadioButton;
    private javax.swing.JComboBox ValuesComboBox;
    private javax.swing.JCheckBox VarEqualCheckBox;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextField mean1TextField;
    private javax.swing.JTextField mean2TextField;
    private javax.swing.JTextField n1TextField;
    private javax.swing.JTextField n2TextField;
    private javax.swing.JTextField stdev1TextField;
    private javax.swing.JTextField stdev2TextField;
    // End of variables declaration//GEN-END:variables
    
}
