QUOTE(Amadeus @ 12 Feb, 2007 - 03:45 PM)

I understand that you are calling a method named addActionPerformed...what I am saying is that you do not have that method defined anywhere, unless it is not here. Can you show me where you have specified what the method addActionPerformed is supposed to do?
Stupid me, instead of addActionPerformed should stand
addActionListener.
Which means that this add stuf is for interfaces not functions.
The code is all OK except for this incompatible types stuf:
CODE
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.lang.*;
public class Kol2_1 extends Applet implements ActionListener
{
Button plus = new Button("+");
Button minus = new Button("-");
Button times = new Button("*");
Button div = new Button("/");
Button eq = new Button("=");
TextField pole = new TextField("E hej zver");
double x=0.0,y=0.0, z;
public void init()
{
try{
x=Double.parseDouble(JOptionPane.showInputDialog("Vnesete vrednost za x:"));
y=Double.parseDouble(JOptionPane.showInputDialog("Vnesete vrednost za y:"));
}
catch(StringIndexOutOfBoundsException n)
{JOptionPane.showMessageDialog(this, "Vnesete broj.");}
setLayout(new GridLayout(4,2));
add(plus);
add(minus);
add(times);
add(div);
add(eq);
add(pole);
plus.addActionListener(this);
minus.addActionListener(this);
times.addActionListener(this);
div.addActionListener(this);
eq.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
switch(e.getSource()){ //incompatible types
case plus: { z=x+y;}
case minus: { z=x-y;}
case times: { z=x*y;}
case div: { try{z=x/y;}
catch(NumberFormatException m)
{
if(y==0) JOptionPane.showMessageDialog(this,"Division by zero.");
}
}
case eq: {pole.setText(""+z);}
}
}
}