Ir para conteúdo



Classe Botoes


  • Por favor, faça o login para responder
Não há respostas para este tópico

#1 Samuel_35

Samuel_35
  • Membros
  • 1 posts

Postado 08 May 2010 - 12:00 PM

Minha classe botoes não está funcionando. Alguém poderia ajudar?
Vejam:

import javax.swing.JButton;
import javax.swing.JPanel;
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JButton;

public class Botoes extends JPanel{
private JButton b1, b2, b3, b4;
private Tratador tr;

public Botoes(){
tr = new Tratador();
b1 = new JButton("CADASTRAR");
b2 = new JButton("LISTAR");
b3 = new JButton("EXCLUIR");
b4 = new JButton("SAIR");
b1.addActionListener(tr);
b2.addActionListener(tr);
b3.addActionListener(tr);
b4.addActionListener(tr);

add(b1);
add(b2);
add(b3);
add(b4);

setLayout(new GridLayout(0,2,0,6));
}



public class Tratador implements ActionListener{
private JButton b1, b2, b3;
public Tratador(JButton ba, JButton bb, JButton bc){
b1 = ba;
b2 = bb;
b3 = bc;
}
public void actionPerformed(ActionEvent acao){
if(acao.getSource() == b1) {
// cadastrar();

} else {
if(acao.getSource() == b2) {
// listar();

} else {
if(acao.getSource() == b3) {
//excluir();

} else {
System.exit(0);
}
}
}
System.out.printf("Ouvinte\t");

}
}
}






0 usuário(s) está(ão) lendo este tópico

0 membro(s), 0 visitante(s) e 0 membros anônimo(s)