Tuesday, April 26, 2011

Generating A Netbeans Project From The Resource Editor


I already had a similar tutorial in the past but this one is more refined and concise (thanks to http://www.screencast-o-matic.com/). This is a simple developer oriented tutorial showing how simple it is to create a hello world application directly to Netbeans and reviewing the output you get as a result.

40 comments:

  1. This seems to be related to the MIDlet you picked in the preview MIDlet probably filling up the RMS.
    Why it happens now and didn't happen before is beyond me. Probably a bug in our mockup RMS implementation but its impossible to tell where from the callstack. You can see our mock RMS implementation n the MIDP-SE project in our SVN trunk.
    You can reset the picked MIDlet using the Application menu in the resource editor.

    ReplyDelete
  2. Thanks Shai

    I reset the picked MIDlet and its working now.

    ReplyDelete
  3. hi,
    I am new to LWUIT RESOURCE EDITOR. can you give me simple steps on how to use generated netbeans project in netbeans. When run the generated project on my mobile it first shows "NOTHING TO DISPALY" AND then it dispalys the UI.

    ReplyDelete
  4. The "Nothing to display" issue is standard Nokia S40 behavior for delayed calls to setCurrent(). Our normal recommendation is to show a splash screen early on to avoid this prompt.

    ReplyDelete
  5. I don't understand how I can make this process clearer than the video?
    When the code is generated you have two classes, StateMachineBase (which subclasses UIBuilder) which you must not modify. It will be regenerated whenever you save the resource file.
    You also have StateMachine which subclasses StateMachineBase and there you can stick your own code. The GUI builder does most of that for you.

    ReplyDelete
  6. Dear Shai hope you're doing just great ... The LWUIT is super ... Now I'm trying to generate a simple GUI as a Netbeans Project an I managed to do so, but the problem is that I can't run it I even tried to use the StatMachine class in a midlett and giving it the resources file's name when I run the midlet it shows the follwing error:

    1.When I Build and Clean it cause no error and generate jar and jad files but when I run them on the phone it gives
    java.lang.NoClassDefFouundError:
    com/sun/lwuit/Display

    2.When I run it in the Netbeans it does show the device but then it shows an error:
    Starting emulator in execution mode
    C:\Users\X\Desktop\mmm\nbproject\build-impl.xml:1054: Execution failed with error code 1.

    now that line shows this code:



    http://www.megaupload.com/?d=WBMAGDYD

    ReplyDelete
  7. hi Shai,
    I Created a Form.It doesnt contain anything.It has one Command named 'SetDevideId', when i click the setdevideid command i need to dispaly a Dialog. I set the command action to my Dialog, but doesnt show me the dialog when i click the command.Command works when there is atleast one button in the Form.

    ReplyDelete
  8. can someone tell me which resource editor is this ..... mine lwuit resource editor doesnt have most of the functions mentioned in the video ...

    ReplyDelete
  9. Hi Shai and everyone,

    I'm using the latest version of the Resource Editor. The problem is when I edit any of the fonts I have already created with a previous Resource Editor version the selected font changes to a default one.

    Any help is appreciated!

    ReplyDelete
  10. Currently sounds other than button pressed aren't yet mapped to any functionality within LWUIT. This is planned for a future release.
    You can override dialog's onShow() method and play the sound manually.

    The fonts in the resource editor had a regression that caused them to render incorrectly. However, they should still work. I fixed this issue in the latest resource editor version.

    ReplyDelete
  11. hi shai,
    I am trying to define events of button but the options in the events tab are not active i.e they are not clickable.Also properties
    preferredW and preferredH are missing in my button's properties tab.

    ReplyDelete
  12. hey Shai,

    every time I try to generate netbeans project or even just create a midlet, it gives me an error
    java.io.IOException: Cannot run program "<--My chosen directory\appname.jar-->": CreateProcess error=2, the system cannot find the file specified

    please help me out with that!

    Rob.

    ReplyDelete
  13. preferredW/H were removed since they were abused quite often and that caused lots of issues. Advanced users who actually understand the significance of changing these values can do this from code.
    The event tab options become active when editing a resource file under the src directory of a generated project. If the options are disabled then LWUIT just didn't find the properties file that is supposed to be in the directory above. I suggest following the video tutorial steps for generating code the first time, once the code is generated everything is seamless.

    First make sure you actually have the right simulator installed to build the app. In the project properties of the base project and the MIDP project check that the right emulator is selected and clean build both of them.

    ReplyDelete
  14. where can i get the LWUIT latest lib jar file?

    ReplyDelete
  15. We only provide LWUIT in source form or in official releases. The last official release is VERY old, we are working on getting the new release out the door and its taking us a while because of bureaucratic delays. Hopefully it will be out soon but we can't guarantee anything since its not up to us.

    ReplyDelete
  16. hi i m using netbeans 6.9 and lwuit 1.4.0.I want to know how and where(statemachine or statemachine)to code (radiobuttons or buttons)in desktop module.how to call component(buttons etc.)in that class(by name or text).

    ReplyDelete
  17. http://stackoverflow.com/questions/6682989/how-to-write-lwuit-radio-button-code/6689404#6689404

    ReplyDelete
  18. When I compile the project generated by GUI Builder the output shows - Error preverifying class generated.StateMachineBase java/lang/NoClassDefFoundError:com/sun/lwuit/util/UIBuilder and it also says Preverification failed with error code:1
    As a result the other projects(MIDP etc) do not compile as the .jar that has the StateMachine code is not generated.

    ReplyDelete
  19. It seems like you are compiling against an old (1.4) version of LWUIT.

    ReplyDelete
  20. Hi Shai hope u r fine,i want to clear some very basic thing let us suppose i create a form Login in resource editor and there is a textfield now i generate netbeans project.I click Textfiled event method in resorce editor I got this method onLogin_TextFieldAction(component c,ActionEvent event ).Now tell me how can i do TextField coding in this method and how can i add listeners and where.

    gaurav

    ReplyDelete
  21. That method is the listener and will be invoked on an action event to the text field.
    There are other callbacks such as before/after form show occurred or on component creation where you can effectively bind listeners to the components returned.
    I suggest you just open the source/GUI for the t-zone demo and step over it with a debugger to see how events are handled there.

    ReplyDelete
  22. hi,
    i want to play a video using a url(HTTP URL). I tried to play that url using the static method VideoComponent.createVideoPeer("http://.........");
    but i am getting nullpointerexception.

    ReplyDelete
  23. I'm guessing the URL isn't supported by the underlying MMAPI implementation but that's just a guess without the stack trace.

    ReplyDelete
  24. Hi Shai

    I'm developing an app with lwuit, i'm using resource editor and netbeans, i've been having this problem, i don't know how to reference any form on the StateMachine without showing it, is there any procedure like showForm that give me a form by the name but without showing it. What i want to do is put some info on the componets that could have a form before showing it.

    Thanks for any help you could give me.

    Edgar

    ReplyDelete
  25. You get a callback before a form actually shows where its best to do such things.

    A form instance doesn't exist before you show it, they are created on the fly to save RAM. You can create a form instance manually using createContainer(formName, resourceFile) however the navigation won't know about this instance and create its own form. It would be helpful if you go into details of what you are trying to achieve.

    ReplyDelete
  26. i'm a little new to this but i want to be able to create a new instance of a textfield and add it when an event occurs say "Button clicked".. but all i'm getting is one textfield replacing the previous.

    ReplyDelete
  27. I'm guessing you are replacing the text field in some way. This should be pretty easy though and you can do it in quite a few ways.
    The first is to have the text field always there but set it to visible false, this might not be appropriate since the text field will still occupy the same space.
    The second approach is to create an area where the text field will be added, a container with an appropriate layout. Then when the button is pressed just use something like: findTextFieldDestContainer(root).addComponent(new TextField());

    ReplyDelete
  28. shalom Shai,
    i insatlled the new sdk(3.0.5), and i have alot of problems with the LwuiT tool.
    (i have NB7.0.1 & JDK7).
    i tried to make simple project such as helloword.but:
    1. wihen i generate the NB project, it caouse to open the NB 4 times!!!!!!
    2. all the project that have been generated with resources problem and erros!!!!
    3. when i fixed the resources problem and tried to run them i have empty screen at the emulator instead the blankform with the helloword label!!!
    4.the RIM project have erros. it didn't find
    import net.rim.device.api.ui.UiApplication;
    and sow it didn't have the UiApplication?
    5. when i tried to run the MIDP project, i have this problem:
    Application descriptor does not declare any MIDlet. Direct execution is not allowed.

    Error preverifying class com.sun.lwuit.impl.midp.CanvasImplementation
    VERIFIER ERROR com/sun/lwuit/impl/midp/GameCanvasImplementation.paintVideo(Lcom/sun/lwuit/Component;ZLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V:
    Cannot find class javax/microedition/media/control/VideoControl
    D:\MyNBProjects\mylwuit01\MIDP\nbproject\build-impl.xml:484: Preverification failed with error code 1.
    BUILD FAILED (total time: 8 seconds)

    6.

    ReplyDelete
  29. Which project?
    You have 5 projects generated for the resource editor.

    ReplyDelete
  30. hey can i ask question??? every time i use generate netbeans project its always error with this The following error occurred while executing this line:Platform home (platform.home property) is not set. Value of this property should be Sun Java(TM) Wireless Toolkit 2.5.2 for CLDC emulator home directory location.
    can you help me figure this out.. im new using this

    ReplyDelete
    Replies
    1. Nugraha, right click on your project, go to properties, select platform, and configure it from there.

      Delete
  31. First, thanks for this tutorial but how I can combined some UI that I've created beside the main UI?

    Then, Can I start generate Netbeans Projects without add the UI just configure the themes?
    And can I write the code after the Netbeans project have created?
    which project that I must write down the code to build my application?

    -Thanks a lots-

    ReplyDelete
  32. Hi guys I have installed all the latest required softwares and used as to the steps followed by the video but I cant generate a single error free project,pls help me guys !

    ReplyDelete
  33. hi there,
    i am trying to explore LWUIT using NetBeans 7.2 I am working on Linux Machine. After a week working with LWUIT, I got to know about LWUIT Designer or known as LWUIT Resource Editor.... But i am not getting how to install / run it on my linux system.

    the .jnlp file for resource editor throws this exception java.security.AccessControlException: access denied (java.util.PropertyPermission microedition.platform read)

    Kindly help regarding this
    Thanks, Swati

    ReplyDelete
  34. Hello everyone i'm new to lwuit and developing some app but it says "MAIN RUNNING NOTHING TO DISPLAY" i want the solution.

    ReplyDelete
  35. i use lwuit 1.5 and netbeand 7. when i generate netbeans project from resource editor its always give me an error that said

    "Problem: The project uses the Java Platform called "Sun Java(TM) Wireless Toolkit 2.5.2 for CLDC", but this platform was not found.
    Solution: Click Resolve and create new platform called "Sun Java(TM) Wireless Toolkit 2.5.2 for CLDC"."

    please help me... i have tried searching for it but no result. asked on stackoverflow but no help.. help me please

    ReplyDelete
  36. and also its doesn't generate MainMIDlet.java file on the project

    ReplyDelete
  37. how to insert an editable table in one of the forms ???? please help

    ReplyDelete
  38. If its the latest version of any of the softwares, I have them. (Netbeans 7.3.1, LWUIT 1.5, JDK7, Java SDK 3.3, J2ME Wireless Toolkit 2.5.2 &Eclipse). I used the LWUIT editor for a few days, However, now when I open the resource editor, 1.) It doesn't show the Themes when I select them in the dialog box, and if I click on anyone of them, the whole App just gets stuck there.

    2.) The GUI doesn't show

    3.) The little tab icons for ''Themes, Images, Fonts, Localization, Data, & GUI Builder'' don't show anymore. Moreover, the LWUIT icon that normally shows on the taskbar now displays the 'JAVA' icon instead.

    Guys, please I REALLY need your help on these issues.

    ReplyDelete