/*
 * EstadoGUI.java
 *
 * Created on November 4, 2002, 11:19 PM
 */

/**
 *
 * @author  gustavo
 */
public class EstadoGUI extends javax.swing.JFrame {
    
    /** Creates new form EstadoGUI */
    public EstadoGUI() {
        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
        jCmBxEstado = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();

        getContentPane().setLayout(null);

        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        jCmBxEstado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Estado1", "Estado2" }));
        jCmBxEstado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCmBxEstadoActionPerformed(evt);
            }
        });

        getContentPane().add(jCmBxEstado);
        jCmBxEstado.setBounds(50, 20, 130, 22);

        jButton1.setText("Actuar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        getContentPane().add(jButton1);
        jButton1.setBounds(80, 50, 81, 23);

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setSize(new java.awt.Dimension(256, 84));
        setLocation((screenSize.width-256)/2,(screenSize.height-84)/2);
    }//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // Add your handling code here:
        stCtx.op1();
        stCtx.op2();
        stCtx.op3();
    }//GEN-LAST:event_jButton1ActionPerformed

    private EstadoContexto stCtx= new EstadoContexto();
    private void jCmBxEstadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCmBxEstadoActionPerformed
        // Add your handling code here:
        String s=jCmBxEstado.getSelectedItem().toString();
        EstadoBase est= null;
        if ("Estado1".equals(s)) {
           est=new Estado1();
        } else if ("Estado2".equals(s)) {
            est=new Estado2();
        } else {
           System.out.println("Opcion no conocida");   
        }
        if (est!=null) { stCtx.cambiarEstado(est);}
        
    }//GEN-LAST:event_jCmBxEstadoActionPerformed
    
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
        System.exit(0);
    }//GEN-LAST:event_exitForm
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        new EstadoGUI().show();
    }
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox jCmBxEstado;
    private javax.swing.JButton jButton1;
    // End of variables declaration//GEN-END:variables
    
}
