Results 1 to 4 of 4
- 02-04-2013, 06:42 PM #1
Member
- Join Date
- Feb 2013
- Posts
- 2
- Rep Power
- 0
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(){
- 02-04-2013, 06:49 PM #2
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[])?
- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 02-04-2013, 06:51 PM #3
Senior Member
- Join Date
- Feb 2009
- Posts
- 303
- Rep Power
- 5
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:
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)
- 02-04-2013, 08:30 PM #4
Member
- Join Date
- Feb 2013
- Posts
- 2
- Rep Power
- 0
Re: invalid method declaration; return type required
Ok thx compilled successfuly. I used this code:
Java 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(); } } }
Similar Threads
-
Invalid method declaration; return type required
By Fate in forum New To JavaReplies: 3Last Post: 03-08-2012, 08:33 PM -
invalid method declaration; return type required
By DeclareVariablesNotWar in forum New To JavaReplies: 10Last Post: 12-13-2011, 02:57 AM -
Invalid method declaration; return type required? Please Help!
By paccerz in forum New To JavaReplies: 2Last Post: 08-23-2011, 10:43 PM -
Invalid Method Declaration; Return Type Required
By bremzb in forum AWT / SwingReplies: 3Last Post: 05-05-2011, 10:12 PM -
invalid method declaration; return type required
By XaviannNJ in forum JCreatorReplies: 7Last Post: 11-25-2010, 01:59 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks