/*
 * Tela.java
 *
 * Created on 9 de Maio de 2008, 21:24
 */

package aula1a;

import javax.swing.JOptionPane;

/**
 *
 * @author  awolf
 */
public class Tela extends javax.swing.JFrame {
    
    /** Creates new form Tela */
    public Tela() {
        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.
     */
    // <editor-fold defaultstate="collapsed" desc=" Código Gerado ">//GEN-BEGIN:initComponents
    private void initComponents() {
        btCliqueme = new javax.swing.JButton();
        btPergunta = new javax.swing.JButton();
        btPega = new javax.swing.JButton();
        btLeva = new javax.swing.JButton();
        tfAlgo = new javax.swing.JTextField();
        btAperta = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        btCliqueme.setText("Clique-me!");
        btCliqueme.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCliquemeActionPerformed(evt);
            }
        });

        btPergunta.setText("Pergunta");
        btPergunta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btPerguntaActionPerformed(evt);
            }
        });

        btPega.setText("Pega");
        btPega.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btPegaActionPerformed(evt);
            }
        });

        btLeva.setText("Leva");

        tfAlgo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfAlgoActionPerformed(evt);
            }
        });

        btAperta.setText("Algo");
        btAperta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btApertaActionPerformed(evt);
            }
        });

        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()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(63, 63, 63)
                        .addComponent(btCliqueme))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(95, 95, 95)
                        .addComponent(btPergunta)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 117, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btLeva)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(btPega)
                        .addGap(54, 54, 54))))
            .addGroup(layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(tfAlgo, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(179, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(266, Short.MAX_VALUE)
                .addComponent(btAperta)
                .addGap(81, 81, 81))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tfAlgo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(23, 23, 23)
                .addComponent(btPega)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btCliqueme)
                    .addComponent(btLeva))
                .addGap(25, 25, 25)
                .addComponent(btPergunta)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btAperta)
                .addContainerGap(117, Short.MAX_VALUE))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void btApertaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btApertaActionPerformed
        btAperta.setText(tfAlgo.getText());
    }//GEN-LAST:event_btApertaActionPerformed
    
    private void tfAlgoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfAlgoActionPerformed
// TODO adicione seu código de manipulação aqui:
    }//GEN-LAST:event_tfAlgoActionPerformed
    
    private void btPegaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btPegaActionPerformed
        System.out.println(btPega.getText());
        btLeva.setText("Nao gostei do texto do botao");
    }//GEN-LAST:event_btPegaActionPerformed
    
    private void btPerguntaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btPerguntaActionPerformed
        if(JOptionPane.showConfirmDialog(null,
                "Voce é queima rosca?",
                "Me Responda",
                JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION){
            JOptionPane.showMessageDialog(null,
                    "Eu sabia",
                    "Aviso",
                    JOptionPane.INFORMATION_MESSAGE);
        }else{
            JOptionPane.showMessageDialog(null,
                    "Para com isso mentiroso",
                    "Aviso",
                    JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_btPerguntaActionPerformed
    
    private void btCliquemeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCliquemeActionPerformed
        System.out.println("A vaca morreu");
    }//GEN-LAST:event_btCliquemeActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Tela().setVisible(true);
            }
        });
    }
    
    // Declaração de variáveis - não modifique//GEN-BEGIN:variables
    private javax.swing.JButton btAperta;
    private javax.swing.JButton btCliqueme;
    private javax.swing.JButton btLeva;
    private javax.swing.JButton btPega;
    private javax.swing.JButton btPergunta;
    private javax.swing.JTextField tfAlgo;
    // Fim da declaração de variáveis//GEN-END:variables
    
}
