/*
 * TransformarCadenaGUI.java
 *
 * Created on September 2, 2002, 6:58 PM
 */

/**
 *
 * @author  gustavo
 */
public class TransformarCadenaGUI extends javax.swing.JFrame {
    
    /** Creates new form TransformarCadenaGUI */
    public TransformarCadenaGUI() {
        initComponents();
        this.jTextCadena.setText("");
    }
    
    /** 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
        jTextCadena = new javax.swing.JTextField();
        jLMsg1 = new javax.swing.JLabel();
        jBminuscula = new javax.swing.JButton();
        jBmayuscula = new javax.swing.JButton();
        jBquitaEspacio = new javax.swing.JButton();
        jLMsg2 = new javax.swing.JLabel();
        jLResult = new javax.swing.JLabel();

        getContentPane().setLayout(null);

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

        jTextCadena.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cadenaAlimentada(evt);
            }
        });

        getContentPane().add(jTextCadena);
        jTextCadena.setBounds(170, 40, 120, 30);

        jLMsg1.setText("Introducir cadena");
        getContentPane().add(jLMsg1);
        jLMsg1.setBounds(30, 40, 140, 30);

        jBminuscula.setText("minusculas");
        jBminuscula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBminusculaActionPerformed(evt);
            }
        });

        getContentPane().add(jBminuscula);
        jBminuscula.setBounds(170, 90, 115, 23);

        jBmayuscula.setText("mayusculas");
        jBmayuscula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBmayusculaActionPerformed(evt);
            }
        });

        getContentPane().add(jBmayuscula);
        jBmayuscula.setBounds(170, 120, 117, 23);

        jBquitaEspacio.setText("quitar Espacios");
        jBquitaEspacio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBquitaEspacioActionPerformed(evt);
            }
        });

        getContentPane().add(jBquitaEspacio);
        jBquitaEspacio.setBounds(170, 150, 160, 30);

        jLMsg2.setText("Resultado");
        getContentPane().add(jLMsg2);
        jLMsg2.setBounds(60, 220, 80, 20);

        getContentPane().add(jLResult);
        jLResult.setBounds(142, 220, 190, 20);

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

    private void jBminusculaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBminusculaActionPerformed
        // Add your handling code here:
        if (cadena != null && !"".equals(cadena)) {
         String res =this.cadena.toLowerCase();
         this.jLResult.setText(res);
        } else {
          this.jLResult.setText("Introducir Cadena");
               
        }
    }//GEN-LAST:event_jBminusculaActionPerformed

    private void jBquitaEspacioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBquitaEspacioActionPerformed
        // Add your handling code here:
         if (cadena != null && !"".equals(cadena)) {
         String res =this.cadena.trim();
         res=this.cadena.replace(' ','\000');
         this.jLResult.setText(res);
        } else {
          this.jLResult.setText("Introducir Cadena");
               
        }
    }//GEN-LAST:event_jBquitaEspacioActionPerformed

    private void jBmayusculaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBmayusculaActionPerformed
        // Add your handling code here:
         if (cadena != null && !"".equals(cadena)) {
         String res =this.cadena.toUpperCase();
         this.jLResult.setText(res);
        } else {
          this.jLResult.setText("Introducir Cadena");
               
        }
    }//GEN-LAST:event_jBmayusculaActionPerformed

    private void cadenaAlimentada(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cadenaAlimentada
        // Add your handling code here:
        this.cadena = this.jTextCadena.getText();
        this.jBmayuscula.setEnabled(true);
        this.jBminuscula.setEnabled(true);
        this.jBquitaEspacio.setEnabled(true);
        this.jLResult.setText("");
    }//GEN-LAST:event_cadenaAlimentada
    
    /** 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 TransformarCadenaGUI().show();
    }
    
    private String cadena="";
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBminuscula;
    private javax.swing.JButton jBquitaEspacio;
    private javax.swing.JLabel jLResult;
    private javax.swing.JLabel jLMsg2;
    private javax.swing.JLabel jLMsg1;
    private javax.swing.JTextField jTextCadena;
    private javax.swing.JButton jBmayuscula;
    // End of variables declaration//GEN-END:variables
    
}
