invalid method declaration; return type required
Hi, I tryed to compile this:
package HelloWorld;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author michal5575
*/
public class Midlet extends MIDlet {
private Display display = null;
private TextBox tbMainForm;
public MIDlet(){
tbMainForm = new TextBox("My First MIDlet","Hello World !",100,0);
}
public void startApp() {
if(display==null)
display = Display.getDisplay(this);
display.setCurrent(tbMainForm);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
And i get this error:
invalid method declaration; return type required
public MIDlet(){
Re: invalid method declaration; return type required
I don't really mess with micro edition, but don't you still need a public static void main(String args[])?
Re: invalid method declaration; return type required
First things first, please use the [CODE] tags when posting code.
Take a look at the following block:
Quote:
Originally Posted by
michal5575
public MIDlet(){
tbMainForm = new TextBox("My First MIDlet","Hello World !",100,0);
}
Is that suppose to be a Constructor for the Midlet class? If so there is something wrong there... (Hint: 1st Line of the following Tutorials Providing Constructors for Your Classes)
Re: invalid method declaration; return type required
Ok thx compilled successfuly. I used this code:
Code:
Test;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class Midlet extends MIDlet implements CommandListener {
private Display display;
private TextBox textBox;
private Command quitCommand;
public void startApp() {
display = Display.getDisplay(this);
quitCommand = new Command("Quit", Command.SCREEN, 1);
textBox = new TextBox("Hello World", "Looks different in Mobile", 40, 0);
textBox.addCommand(quitCommand);
textBox.setCommandListener(this);
display.setCurrent(textBox);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command choice, Displayable displayable) {
if (choice == quitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}