Hi Leutz,
kan mir da jemand helfen?
package Anfang;
import java.awt.*;
import java.awt.event.*;
/**
* @author LittleWulf
*
*/
public class Grafiken extends Frame implements ActionListener {
Button bt1, bt2;
Canvas cv;
public Grafiken (){
cv = new Canvas();
cv.setBounds(50,100,200,300);
cv.setBackground(Color.yellow);
add (cv);
setLayout (new FlowLayout());
bt1 = new Button ("Kreis");
add (bt1);
bt1.addActionListener (this);
bt2 = new Button ("Gerade");
add (bt2);
bt2.addActionListener (this);
initComponenets ();
}
private void initComponenets ()
{
addWindowListener (new WindowAdapter (){
public void windowClosing (WindowEvent ev){
exitForm(ev);}});
pack ();}
private void exitForm (WindowEvent ev) {
System.exit(0);}
public static void main(String[] args) {
Grafiken toll = new Grafiken ();
toll.setLocation (100,100);
toll.setSize (350,380);
toll.show ();
}
public void kreis(int xm,int ym,int r){
Graphics g = cv.getGraphics();
g.setColor(Color.white);
int x1 = xm - r;
int y1 = xm - r;
g.drawOval(x1,y1,2*r,2*r);
g.dispose();}
public void maleGerade (int x1,int y1,int x2,int y2){
Graphics g = cv.getGraphics();
g.setColor(Color.red);
for(int i = 1;i<10;i++)
g.drawLine(i*x1,i*y1,x2,y2);
g.dispose();}
public void actionPerfomed(ActionEvent e){
if(e.getSource()==bt1) kreis(50,20,100);
if(e.getSource()==bt2) maleGerade(10,20,100,200);
}
}
Und Fehler zeigt er des:
java.lang.Error: Unresolved compilation problem:
Class must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent)
at Anfang.Grafiken.actionPerformed(Grafiken.java:13)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)