/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * QuestionChoiceView.java
 *
 * Created on Nov 21, 2009, 5:34:53 PM
 */

package cstutor.quizcreation;

/**
 *
 * @author Josh Robinson
 */
public class QuestionChoiceView extends javax.swing.JFrame {

    /** Creates new form QuestionChoiceView */
    public QuestionChoiceView() {
        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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        questionChoiceBG = new javax.swing.ButtonGroup();
        multChoiceRB = new javax.swing.JRadioButton();
        interactiveRB = new javax.swing.JRadioButton();
        cancelB = new javax.swing.JButton();
        questionTypeL = new javax.swing.JLabel();
        okB = new javax.swing.JButton();

        setResizable(false);

        questionChoiceBG.add(multChoiceRB);
        multChoiceRB.setText("Add a Multiple Choice Question");
        multChoiceRB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                multChoiceRBActionPerformed(evt);
            }
        });

        questionChoiceBG.add(interactiveRB);
        interactiveRB.setText("Add an Interactive Question");
        interactiveRB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                interactiveRBActionPerformed(evt);
            }
        });

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

        questionTypeL.setFont(new java.awt.Font("Tahoma", 1, 18));
        questionTypeL.setText("Choose a Question Type:");

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

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(questionTypeL)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(cancelB)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 111, Short.MAX_VALUE)
                        .addComponent(okB))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(interactiveRB)
                            .addComponent(multChoiceRB))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(questionTypeL)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(multChoiceRB)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(interactiveRB)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(okB)
                    .addComponent(cancelB))
                .addContainerGap())
        );

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

    private void multChoiceRBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multChoiceRBActionPerformed
        // TODO add your handling code here:
        isMultChoice = true;
    }//GEN-LAST:event_multChoiceRBActionPerformed

    private void interactiveRBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_interactiveRBActionPerformed
        // TODO add your handling code here:
        isMultChoice = false;
    }//GEN-LAST:event_interactiveRBActionPerformed

    private void cancelBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
    }//GEN-LAST:event_cancelBActionPerformed

    private void okBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okBActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
        if(isMultChoice) {
            MultipleChoiceView mcv = new MultipleChoiceView();
            mcv.setVisible(true);
        } else {
            InteractiveView iv = new InteractiveView();
            iv.setVisible(true);
        }
    }//GEN-LAST:event_okBActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new QuestionChoiceView().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelB;
    private javax.swing.JRadioButton interactiveRB;
    private javax.swing.JRadioButton multChoiceRB;
    private javax.swing.JButton okB;
    private javax.swing.ButtonGroup questionChoiceBG;
    private javax.swing.JLabel questionTypeL;
    // End of variables declaration//GEN-END:variables
    private boolean isMultChoice;
}