setPosition error

Hi all

I'm a beginning Java programmer! I'm working with PHP, MySQL and HTML already for 3 months but Java still 2 weeks. Now i made this code (Ya, really made by myself :P):

import java.applet.Applet;

import java.awt.*;

import java.awt.event.*;

publicclass staprekenextends Appletimplements ActionListener

{

double telling[] ={"nul","een","twee","drie","vier","vijf","zes","zeven","acht","negen","plus","min","keer"};

int nummereen;

int nummertwee;

String soort;

int vakje = 0;

TextField first;

TextField type;

TextField second;

TextField answer;

Button nul;

Button een;

Button twee;

Button drie;

Button vier;

Button vijf;

Button zes;

Button zeven;

Button acht;

Button negen;

Button plus;

Button min;

Button keer;

publicvoid init()

{

setLayout(null);

first =new TextField(1);

first.setSize(100, 20);

first.setPosition(20, 20);

add(first);

type =new TextField(1);

type.setSize(50, 20);

type.setPosition(80, 20);

add(type);

second =new TextField(1);

second.setSize(100, 20);

second.setPosition(190, 20);

add(second);

answer =new TextField(1);

answer.setSize(100, 20);

answer.setPosition(300, 20);

add(answer);

nul =new Button("0");

nul.setSize(20, 20);

nul.setPosition(20, 100);

nul.addActionListener(this);

add(nul);

een =new Button("1");

een.setSize(20, 20);

een.setPosition(50, 100);

een.addActionListener(this);

add(een);

twee =new Button("2");

twee.setSize(20, 20);

twee.setPosition(80, 100);

twee.addActionListener(this);

add(twee);

drie =new Button("3");

drie.setSize(20, 20);

drie.setPosition(20, 100);

drie.addActionListener(this);

add(drie);

vier =new Button("4");

vier.setSize(20, 20);

vier.setPosition(50, 130);

vier.addActionListener(this);

add(vier);

vijf =new Button("5");

vijf.setSize(20, 20);

vijf.setPosition(80, 130);

vijf.addActionListener(this);

add(vijf);

zes =new Button("6");

drie.setSize(20, 20);

drie.setPosition(20, 130);

drie.addActionListener(this);

add(drie);

zeven =new Button("7");

drie.setSize(20, 20);

drie.setPosition(110, 160);

drie.addActionListener(this);

add(drie);

acht =new Button("8");

drie.setSize(20, 20);

drie.setPosition(50, 160);

drie.addActionListener(this);

add(drie);

negen =new Button("9");

drie.setSize(20, 20);

drie.setPosition(80, 160);

drie.addActionListener(this);

add(drie);

plus =new Button("+");

drie.setSize(20, 20);

drie.setPosition(110, 100);

drie.addActionListener(this);

add(drie);

min =new Button("-");

drie.setSize(20, 20);

drie.setPosition(110, 130);

drie.addActionListener(this);

add(drie);

keer =new Button("*");

drie.setSize(20, 20);

drie.setPosition(110, 160);

drie.addActionListener(this);

add(drie);

}

publicvoid actionPerformed(ActionEvent clicked)

{

if (vakje == 0)

{

int getal = 0;

while (getal < 10){

if (clicked.getSource() == telling[getal]){

first.setText(getal);

getal = getal + 1;

vakje = vakje + 1;

nummereen = getal;

}

}

}

if (vakje == 1)

{

if (type.getText() =="+")

{

soort ="+";

type.setText(soort);

vakje = vakje + 1;

}

if (type.getText() =="-")

{

soort ="-";

type.setText(soort);

vakje = vakje + 1;

}

if (type.getText() =="*")

{

soort ="*";

type.setText(soort);

vakje = vakje + 1;

}

}

if (vakje == 2)

{

int getal = 0;

while (getal < 10){

if (clicked.getSource() == getal){

second.setText(getal);

getal = getal + 1;

vakje = vakje + 1;

nummertwee = getal;

}

}

}

if (vakje == 3)

{

if (soort =="+")

{

int einde = nummereen + nummertwee;

answer.setText(einde);

vakje = 0;

}

if (soort =="-")

{

int einde = nummereen - nummertwee;

answer.setText(einde);

vakje = 0;

}

if (soort =="*")

{

int einde = nummereen * nummertwee;

answer.setText(einde);

vakje = 0;

}

}

}

}

But i got an error: Cannot find symbol method setPosition(int, int) and incompatible types on line 6!

Could anybody help me plz!

TY, Jasper91

Message was edited by:

Jasper91

[8909 byte] By [Jasper91a] at [2007-10-2 21:05:36]
# 1

When you ask for help with error messages, it is best to copy and paste them in your message. Also, the error message normally tells you what line in which file the error occurred. If you can tell us which lines cause the problem, it helps you get better answers.

In your case, it is easy to tell which line is causing the incompatible types. You have double telling[] = {"nul"... You are saying telling is an array of double values but then you supply Strings as the values for the doubles. You can not do this. Either telling is an array of Strings or you need double values (like 1.5) in your list of values.

The cannot find symbol message is saying that the compiler can not find a setPosition() method that takes two ints as arguments. If you check the Java API, you will find that classes like TextField and Button do not have a setPosition() method. What were you trying to accomplish with these method calls? Were you trying to specify where in the applet these components should be placed? If so, that is not how position components in Java.

atmguya at 2007-7-13 23:50:56 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...