faça
b1.addActionListener(this);
b2.addActionListener(this);
----- Original Message -----
From: "Roberto A. Metz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 21, 2001 12:58 PM
Subject: [java-list] Erro no tratamento de Eventos
> Ola Lista ...
> Estou tendo problemas neste programinha (applet) besta, ele retorna isso:
> --------------------------- Compiler Output ---------------------------
> Folha5.java:29: addActionListener(java.awt.event.ActionListener) in
> java.awt.Button cannot be applied to ()
> b1.addActionListener();
> ^
> Folha5.java:30: addActionListener(java.awt.event.ActionListener) in
> java.awt.Button cannot be applied to ()
> b2.addActionListener();
> ^
> 2 errors
> --------------------------------------------------------------------------
--
> -
> Devo não estar usando os "ouvintes" da forma certa, se alguem puder me dar
> uma mão ...
>
> import java.applet.*;
> import java.awt.*;
> import java.awt.event.*;
>
> public class Folha5 extends Applet implements ActionListener
> {
> Button b1, b2;
> String X;
>
> public void paint(Graphics g)
> {
> if ( X != null)
>
> g.drawString(X, 80, 80);
> }
>
> public void init()
> {
> Folha5 f = new Folha5();
>
> b1 = new Button();
> b2 = new Button();
>
> f.setLayout( new FlowLayout() );
>
> f.add( b1 );
> f.add( b2 );
>
> b1.addActionListener();
> b2.addActionListener();
> }
>
> public void actionPerformed(ActionEvent e)
> {
> if ( e.getSource().equals(b1) )
> {
> X = "Botão 1 pressionado";
> repaint();
> }
> else
>
> if ( e.getSource().equals(b2) )
> {
> X = "Botão 2 pressionado";
> repaint();
>
> }
>
> }
>
> }
> =================================
> Roberto A. Metz
> Universidade de Passo Fundo - RS
> [EMAIL PROTECTED]
> http://carazinho.upf.tche.br/~9430
> =================================
>
>
> ------------------------------ LISTA SOUJAVA ----------------------------
> http://www.soujava.org.br - Sociedade de Usuários Java da Sucesu-SP
> dúvidas mais comuns: http://www.soujava.org.br/faq.htm
> regras da lista: http://www.soujava.org.br/regras.htm
> para sair da lista: envie email para [EMAIL PROTECTED]
> -------------------------------------------------------------------------
>
------------------------------ LISTA SOUJAVA ----------------------------
http://www.soujava.org.br - Sociedade de Usuários Java da Sucesu-SP
dúvidas mais comuns: http://www.soujava.org.br/faq.htm
regras da lista: http://www.soujava.org.br/regras.htm
para sair da lista: envie email para [EMAIL PROTECTED]
-------------------------------------------------------------------------