Olá pessoal!
Estou com problemas na hora de clicar no botão ele não retorna o txtfield.
Veja se esqueci de algo!
/*
* Cad_banco.java
*
* Created on November 4, 2005, 5:27 PM
*
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
*/
package br.com.sifi.dao.interfaces;
import br.com.sifi.controle.Controle;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*
* @author chris
*/
public class Cad_banco extends JFrame {
private JLabel lbl,lbl1, lbl2, lbl3, lbl4, lbl5, lbl6, lblIcone;
private JTextField txt1, txt2, txt3;
private JButton btn1, btn2;
private JComboBox cbx;
private String tipo[] = {"","Conta Corrente","Conta Poupança"};
private String banco;
/** Creates a new instance of Cad_banco */
public Cad_banco() {
super("Cadastro de Conta Corrente");
Container container = getContentPane();
container.setLayout(null);
Icon icon1 = new ImageIcon("/home/ccarvalho/Projetos/Sifi/src/br/com/sifi/dao/interfaces/imagens/logo2.jpg");
lblIcone = new JLabel(icon1);
lblIcone.setBounds(10,10,100,42);
container.add(lblIcone);
lbl1 = new JLabel("Cadastro de Conta Corrente");
lbl1.setBounds(120,30,200,15);
container.add(lbl1);
lbl2 = new JLabel("Banco:");
lbl2.setBounds(10,63,70,15);
container.add(lbl2);
txt1 = new JTextField(10);
txt1.setBounds(95,63,200,17);
container.add(txt1);
lbl3 = new JLabel("Nº Agência:");
lbl3.setBounds(10,83,80,17);
container.add(lbl3);
txt1 = new JTextField(10);
txt1.setBounds(95,83,200,17);
container.add(txt1);
lbl4 = new JLabel("Tipo:");
lbl4.setBounds(10,103,80,17);
container.add(lbl4);
cbx = new JComboBox(tipo);
cbx.setMaximumRowCount(4);
cbx.setBounds(95,103, 200, 17);
container.add(cbx);
lbl5 = new JLabel("Nº Conta:");
lbl5.setBounds(10,123,70,15);
container.add(lbl5);
txt2 = new JTextField(150);
txt2.setBounds(95,123,200,17);
container.add(txt2);
lbl6 = new JLabel("Responsável:");
lbl6.setBounds(10,143,90,15);
container.add(lbl6);
txt3 = new JTextField(150);
txt3.setBounds(95,143,200,17);
container.add(txt3);
btn1 = new JButton("Cadastrar");
btn1.setBounds(60,169,95,25);
btn1.addActionListener(
new java.awt.event.ActionListener() {
Controle controle = new Controle();
public void actionPerformed(java.awt.event.ActionEvent evt) {
banco = txt1.getText();
System.out.println("Banco " + banco);
controle.incluirBancoAction(evt, banco);
}
}
);
container.add(btn1);
btn2 = new JButton("Cancelar");
btn2.setBounds(165,169,95,25);
container.add(btn2);
setSize(325,245);
setVisible(true);
setResizable(false);
setLocationRelativeTo(null);
}
public static void main(String args[]){
Cad_banco application = new Cad_banco();
application.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE);
}
}
Classe Controle
/*
* Controle.java
*
* Created on 2 de Agosto de 2006, 15:36
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package br.com.sifi.controle;
import br.com.sifi.dao.interfaces.Cad_banco;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
/**
*
* @author ccarvalho
*/
public class Controle implements ActionListener{
public void incluirBancoAction(ActionEvent evt, String msg) {
JOptionPane.showMessageDialog(null, "Mensagem" + msg);
}
}