hoffe mal dass das hier hin passt....
also folgendes: hab meine gui programmiert, alles schön und gut so weit. nun wollte ich noch einfach schnell 2 actionlistener auf die buttons raufmachen, geht nicht!(laut eclipse, fehler hab ich mal markiert). was mach ich falsch?
ist bestimmt was ganz banales....anfängerfragen halt!
danke schon mal im voraus!
ps: falls der genaue fehlercode erwünscht ist sagen.
also folgendes: hab meine gui programmiert, alles schön und gut so weit. nun wollte ich noch einfach schnell 2 actionlistener auf die buttons raufmachen, geht nicht!(laut eclipse, fehler hab ich mal markiert). was mach ich falsch?
ist bestimmt was ganz banales....anfängerfragen halt!
danke schon mal im voraus!
ps: falls der genaue fehlercode erwünscht ist sagen.
Code:
/**
* @author xxx
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.awt.*;
import java.awt.event.*;
import java.util.EventListener;
import javax.swing.*;
public class ChoicePanel extends JPanel implements ActionListener{
private JButton Client;
private JButton Server;
private JLabel oben;
private ActionListener e;
public ChoicePanel()
{
this.setVisible(true);
this.setFocusable(true);
this.requestFocus();
this.setPreferredSize(new Dimension(500, 350));
this.setLayout(null);
Client= new JButton ("Client");
Client.setBounds(50, 150, 200, 25);
Client.addActionListener<---DA SAGT ER FEHLER(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
new Clientmenue();
}
});
Server= new JButton ("Server");
Server.setBounds(250, 150, 200, 25);
oben= new JLabel ("Bitte wählen:");
oben.setBounds(210, 75, 200, 25);
this.add(Client);
this.add(Server);
this.add(oben);
}
public interface ActionListener extends EventListener
{
void actionPerformed( ActionEvent c );
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent arg0) {
new Clientmenue();
}
}