new Thread and error symbol:Constructor

Hi everybody, i'm a new to java

I have written a dictionary application for my mobile. The program works fine with this code:

...

publicvoid commandAction(Command c, Displayable p)

{

if (c == WN.cmdBack)

{

display.setCurrent(parent);

}

elseif (c == WN.cmdSelect)

{

int selected = getSelectedIndex();

if (selected >= 0)

{

Definition definition =new Definition(wordLists, selected);

ResultForm resultForm =new ResultForm(definition.word, definition.def, display,this);

display.setCurrent(resultForm);

}

}

}

...

But the Toolkit said that i should create a new thread, so I changed the code to:

publicvoid commandAction(Command c, Displayable p)

{

if (c == WN.cmdBack)

{

display.setCurrent(parent);

}

elseif (c == WN.cmdSelect)

{

new ThreadResult().start();

}

}

publicclass ThreadResultextends Thread

{

publicvoid run()

{

try

{

int selected = getSelectedIndex();

if (selected >= 0)

{

Definition definition =new Definition(wordLists, selected);

resultForm =new ResultForm(definition.word, definition.def, display,this);

display.setCurrent(resultForm);

}

}

catch (Exception ex)

{

thrownew Error("Err.#3\n" + ex);

}

}

}

ResultForm.java:

publicclass ResultFormextends Formimplements CommandListener

{

private Display display;

private Displayable parent;

public ResultForm(String w, String m, Display d, Displayable p)

{

super(w +":");

display = d;

parent = p;

append(m);

addCommand(WN.cmdBack);

setCommandListener(this);

}

publicvoid commandAction(Command c, Displayable p)

{

if(c == WN.cmdBack)

{

display.setCurrent(parent);

}

}

}

but it says error when compiling:

cannot find symbol

symbol : constructor ResultForm(java.lang.String,java.lang.String,javax.microedition.lcdui.Display,BuildList.ThreadResult)

location: class ResultForm

resultForm = new ResultForm(definition.word, definition.def, display, this);

^

I don't know why, please help...

Thanks in advance.

[4654 byte] By [Replikaa] at [2007-11-27 6:55:24]
# 1

Dear Replika,

Your problem is simple you forgot to add the data type of resultForm meaning it should be this way :-

ResultForm resultForm = new ResultFrom(definition.word, definition.def, display, this);

this syntax was correct in your initial code.

Regards,

JKuhen

JKuhena at 2007-7-12 18:31:04 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

JKuhen, thank you for your replying.

That is my typing mistake (sorry), because I tried alot before so I put:

public ResultForm resultForm

at the first.

I still have this error :(

My program opens 2 threads:

midlet "WN" -> new thread search -> build the word list (hint) -> new thread that show the definition.

In showing definition, if I do in normal, the program works fine, but if I do it in a new thread, the compiler shows that error.

Replikaa at 2007-7-12 18:31:04 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
Sorry again, I think I've found the answer.In:ResultForm resultForm = new ResultForm(definition.word, definition.def, display, this);this points to class ThreadResult !, not the parent class
Replikaa at 2007-7-12 18:31:04 > top of Java-index,Java Mobility Forums,Java ME Technologies...