Jimmy's Blog

Basic LWUIT tutorial/sample with Eclipse Pulsar

by jimmy on Apr.17, 2010, under English, Java, Programming, Technology

I was really want to try LWUIT since several months ago. It’s look promising and it’s developed by SUN so I think every Java ME developer should take a look on this technology.
I’m also still new in LWUIT so there won’t be a lot that I can share for now, but at least I will show you a basic demonstration of how to use Form, Label, Command, and 3D Form transition (sound cool huh :p)

REQUIREMENT

What you need:

  1. LWUIT
  2. Eclipse Pulsa
  3. Emulator like Sun WTK
  4. Know basic Java ME programming :)

CONFIGURE ECLIPSE

First you need to setup your emulator in Eclipse.
Run your Eclipse and select at the menu : Window – Preferences
Select : Java ME – Device Management – click Import
Then browse to your emulator folder, it will scan and give you option to add it to your device list.

Eclipse Pulsar Device Management

Eclipse Pulsar Device Management

*I found that the automatic javadoc folder detection for each jar library is not all correct (I’m using Ubuntu 9.04, WTK 2.5.1)

CREATE NEW MIDlet PROJECT & CONFIGURE

Ok, now we ready to create the new project.
I assume you already know how to use Eclipse properly, create a new MIDlet Project there you will select your default emulator you want to use in the project, MIDP – CLDC version, etc.
After the new project created we gonna add the LWUIT library to the project.
Right click on the project (at package explorer) and select Properties.
Select ‘Java Build Path’ and tab ‘Libraries’ then click ‘Add External Jars’ and browse to select where your LWUIT jar is. (It will be on the lib folder where you extract you LWUIT zip)

MIDlet Project Properties

MIDlet Project Properties

You will see the LWUIT.jar shown.
Select tab ‘Order and Export’, check the LWUIT.jar library so it will be included in our application jar.

Pulsa MIDlet project order and export

Pulsa MIDlet project order and export

One of the cool thing about LWUIT is theme feature, you can see there’s ResourceEditor in LWUIT’s ‘util’ folder it’s for editing theme.
Let’s use default theme from the package. Copy file that located at ./LWUITDemo/src/LWUITtheme.res to our project ‘res’  folder (you can drag ‘n drop it to Eclipse).

THE CODING

Now we finally get to real coding.
Add a new MIDlet to the project. In my example I will create BasicForm Class:

package gnu.jimmy.blog.lwuit;
 
import java.io.IOException;
 
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
 
import com.sun.lwuit.Command;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.animations.Transition3D;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;
 
public class BasicForm extends MIDlet implements ActionListener {
 
	private Form form1;
	private Form form2;
 
	private Command cmdRotate = new Command("Rotate");
	private Command cmdSlide = new Command("Slide");
	private Command cmdExit = new Command("Exit");
 
	public BasicForm() {
		//Initialize the LWUIT
		Display.init(this);
	}
 
	protected void startApp() throws MIDletStateChangeException {
		//Load the Theme
		Resources r;
		try {
			r = Resources.open("/LWUITtheme.res");
			UIManager.getInstance().
			setThemeProps(r.getTheme("LWUITDefault"));
		} catch (IOException e) {
			e.printStackTrace();
		}
 
		//Setup Form 1
		form1 = new Form("Form 1");
		form1.setLayout(new BorderLayout());
		form1.addComponent(BorderLayout.NORTH, new Label("My First Form"));
		form1.addComponent(BorderLayout.WEST, new Label("WEST"));
		form1.addComponent(BorderLayout.CENTER, new Label("CENTER"));
		form1.addComponent(BorderLayout.EAST, new Label("EAST"));
		form1.addComponent(BorderLayout.SOUTH, new Label("Click Rotate"));
		form1.addCommand(cmdRotate);
		form1.addCommand(cmdExit);
		form1.addCommandListener(this);
		form1.setTransitionInAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, true, 1000));
 
		//Setup Form 2
		form2 = new Form("Form 2");
		form2.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
		form2.addComponent(0,null,new Label("This is the second Form"));
		form2.addCommand(cmdSlide);
		form2.addCommand(cmdExit);
		form2.addCommandListener(this);
		form2.setTransitionInAnimator(Transition3D.createCube(1000, true));
 
		form1.show();
	}
 
	public void actionPerformed(ActionEvent evt) {
		//check which command cliked
		if (evt.getCommand()==cmdExit) {
			notifyDestroyed();
		} else if (evt.getCommand()==cmdRotate) {
			form2.show();
		} else if (evt.getCommand()==cmdSlide) {
			form1.show();
		}
	}
 
	protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
	}
 
	protected void pauseApp() {
	}
 
}

Try to run the class.
It should display a form and when you click the left softkey change to the second form with cube rotate effect.
When you click the left softkey again it will go back to first form with slide effect.

LWUIT sample

LWUIT sample

NOTE
* all  UI classes are from package com.sun.lwuit don’t import the WTK default.
* Display.init function (the one I put in constructor) needed to execute first before initializing Forms
* Theme need to be load first before initializing Forms
* Transition3D will require M3G, so if you want to test it on real phone make sure your phone support it. If not you can just change the Transition3D to CommonTransition.

ENDING

If you have prompt to follow the tutorial just drop me a comment here.

Cheers :)

Related posts:

  1. Java ME (J2ME) JSON Implementation Tutorial/Sample
  2. Jimmy’s Blog – Send & Receiving SMS on specific Port with J2ME Application
  3. Jimmy’s Blog – ISO 8583 Tutorial – Build and Parse ISO Message using JPOS library
  4. Jimmy’s Blog – Slide Number Puzzle Game with Echo2 Framework
  5. Simple Log4J implementation

:, , , , , , , , , , , , ,

47 Comments for this entry

  • Talavang

    hi
    am having a lot of problems with this…

    java.lang.NullPointerException: 0
    at com.sun.lwuit.Display.getResourceAsStream(Display.java:1665)
    at com.sun.lwuit.util.Resources.open(Resources.java:448)
    at hello.HelloMIDlet.startApp(HelloMIDlet.java:768)
    at javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
    at com.sun.midp.midlet.MIDletPeer.startApp(), bci=7
    at com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=269
    at com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
    at com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
    at com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
    at com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26

    any help ????

  • jimmy

    @talavang:
    Can you put a snippet of your code, especially on the part that causing exception. Looks like your HelloMIDlet.startApp()

    It’s look like there’s error when loading a resource, check your image file, theme file or other files used is exists.
    *If you used Eclipse remember to refresh your project folder after you put file from file-manager

  • David Williams

    I get a compile error saying the Method for
    formX.addCommandListener(this) is undefined.

  • jimmy

    @David:
    Make sure you import the correct class.
    Since LWUIT Form using same class name like the original MIDP Form.

    Check your import statement above and make sure it’s:
    import com.sun.lwuit.Form;

    if you’re using “import javax.microedition.lcdui.Form;” just change it to lwuit package.

  • David Williams

    Jimmy,

    I just followed your steps here and cut and pasted this example above
    and got that error. I’ll check and see what’s going on soon and let you
    know what I found out. Thanks for responding so quick…..
    I’d like to use this for a simple example at the appconlv.com show comming up in Aug…Where I’ll also be talking about LWUIT that I’m been working with Thorston on compiling in ANT for Blackberry and Android….

  • jimmy

    David,
    From your error “formX.addCommandListener(this) is undefined.” what comes to my mind is the form is not LWUIT Form.
    Because addCommandListener() method is not exist in original MIDP Form (it use setCommandListener() )

    Let me know if you still didn’t found the error cause.

    Wow appcon, cool :)

  • Frej

    Hi, I’ve followed every step but when I run I get this message:
    Syntax:

    emulator [arguments]

    In order to get commands supported by given device run:
    emulator.exe -Xdevice: -Xquery

    Generic list of arguments is:

    -version Display version information about the emulator
    -help Display list of valid arguments
    -classpath, -cp The class path for the VM
    -D= Set a system property
    -Xdebug Use a remote debugger
    -Xrunjdwp:[transport=,address=,server=
    suspend=]
    Debugging options
    -Xdevice: Select a device skin for the emulator
    -Xdomain:
    Set the MIDlet suite’s security domain

    -Xquery Print device information
    -Xjam[:install= | force | list | storageNames |
    run=[ | ] |
    remove=[ | | all]]
    Java Application Manager and support
    for Over The Air provisioning (OTA)
    -Xautotest:
    Run in autotest mode
    -Xdescriptor:
    The JAD file to be executed

    Can’t find what’s wrong :S

  • jimmy

    Frej,
    Can you explain your environment:
    - what OS do you use?
    - IDE: Eclipse Pulsar?

    It’s like you’re configuration is wrong, and the emulator execution didn’t have the correct parameter

  • Frej

    Got Windows 7, and correct, I use Eclipse Pulsar.

    When I’ve searched for emulators in maps like Sun WTK, I get differnt emulator-options. Could it be as simply as that I chose wrong?

  • Obaid

    Hello
    I m using EclipseMe. I have used your sample in a new j2me project. I am getting the following Exception while running

    Connected to KVM
    java.lang.NoClassDefFoundError: com/sun/lwuit/Label
    at hello.HelloMIDlet.(+9)
    at java.lang.Class.runCustomCode(+0)
    at com.sun.midp.midlet.MIDletState.createMIDlet(+34)
    at com.sun.midp.midlet.Scheduler.schedule(+52)
    at com.sun.midp.main.Main.runLocalClass(+28)
    at com.sun.midp.main.Main.main(+80)
    Execution completed.

  • jimmy

    @Frej:
    What WTK do you used? WTK 2.5.2?
    When you import devices did you success seeing 4 SUN device (default color phone, etc)?

    @Obaid:
    Seems like you didn’t include the lwuit.jar into you jar application.
    Make sure your check the lwuit.jar on the “order and export” tab.
    like above image : http://jimmod.com/blog/wp-content/uploads/2010/04/Properties-Order-and-Export.png

  • Obaid

    I have added the LWUIT.jar as well as checked that lwuit.jar on the “order and export” tab.

    I can run a project created in Eclipse successfully without using external jar.
    This problem is coming only when i m using an external jar like this “lwuit.jar”

    Also, i had created a project in NetBeans using this jar. The project is running fine in Netbeans but the same project when brought in Eclipse and converted into j2me project using project properties->j2me->Convert to…
    The same issue is occuring. The project is building fine. There are no errors. But at runtime this exception is coming :(

    May be any project setting or Eclipse setting required !!!
    Any suggestions ?

  • jimmy

    Obaid:
    Strange, when you check it in ‘order and export’ it should included in your application jar.
    Have you try to open your app jar (with winzip or other) to see if the class from LWUIT is included?

    Other way is to get LWUIT source code and put it in your project. So use the source code rather than the library (lwuit.jar)

  • morgan

    Damn….. I wasted one day to figure out why this example doesn’t working…..

    //Setup Form 2
    form2 = new Form(”Form 2″);
    form1.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    ^^^

    that should be form2 not form1 …..

  • jimmy

    @Morgan:
    oops, I mistyped that one.
    I’ve updated.
    Many thanks.

  • Eran

    Great tutorial! Got me swimming in two minutes. Thanks :)

  • Alex

    When I run this code, the emulator window (juts a view of some mobile-phone) appeared just for a second or two. Then it disappeared.

    My LWUIT version is 1.4.

    I looks like something about the security.
    The console message is the following:

    Running with storage root C:\***\***\j2mewtk\2.5.2\appdb\DefaultColorPhone
    Running with locale: English_United States.1252
    Running in the identified_third_party security domain
    java.lang.ClassNotFoundException: MyPhone/BasicForm
    at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
    at com.sun.midp.midlet.Scheduler.schedule(+52)
    at com.sun.midp.main.Main.runLocalClass(+28)
    at com.sun.midp.main.Main.main(+80)
    Execution completed.
    3399019 bytecodes executed
    18 thread switches
    1667 classes in the system (including system classes)
    17548 dynamic objects allocated (522016 bytes)
    1 garbage collections (0 bytes collected)

  • David Williams

    Alex,

    The Trace Say’s it can’t find the Class.

    java.lang.ClassNotFoundException: MyPhone/BasicForm

    Keep in mind that the Static Class
    Display() is for MIDlet to initilize the MIDP Display
    where
    Display.init()
    These come from two different libraries.

    I can’t tell you exactly what all is wrong but
    when you extend MIDlet as the parent class that expected to be inited from LWUIT Library via Display.init()
    You can intermix the Libraries of LWUIT and Liquic Crystal Display but you have to esentially flip flop which Display your Using.. The Static Display class is the glue into the Life Cycle of the application and MIDP is Different than LWUIT as well as CLDC for Blackberry Applications (UIApplication)

  • David Williams

    All,
    What I discovered when working with the Blackberry Port of LWUIT was to not confuse your Imports and if you are having trouble try fully qualifying your classes so you can be sure they are comming from the com.sun.xxx Libraries. For example: Instead of Display.
    com.sun.lwuit.WHATEVER just to make sure your not in some other MIDP Class. LWUIT has it’s own classes Display wise but it’s “Fitted” Into the Life Cycle of MIDP. The Relationships between them is that the Static Class Display.getCurrent… Normally used in MIDP but in LWUIT the Display is initilized Display.init…
    There is a UIDemo included in the LWUIT download but it’s short a few resources which you can get from the Sprint Wireless Toolkit.. Just yank the Mission Resources out of that and put them into your Eclipse RES and you can get a Clean Compile with that.
    If you are coding for a Blackberry or Android, be sure and get the respective Implementations for those. Blackberry Implementation does work with Touch Screen Events for Blackberry. Get Thorsten’s Version from Incubator. That’s compiles the libs under Eclipse if you simply comment 1 line.
    I have got those Compiled in Eclipse and used them to
    compile the UIDemo as well as Jimmy’s Demo here but i believe I removed the MIDP Imports lines to avoid crossing over classes. You have to be real careful to get LWUIT over Liquid Crystal Display. The Two don’t mix unless you are careful to “Swap” Your current Display. Use ASK.com and looking up mixing LCDUI with LWUIT for more info.

  • Bala

    Hi,
    Thank you for the tutorial. Could you point me to an article/tutorial on how to call an RESTful webservice from within j2ME application?
    Regards

  • Vinícius E.

    Thanks! Great guide and it worked just fine.

  • chris

    Hi,

    I got the following error when following the tutorial:

    java.lang.ClassNotFoundException: gnu/jimmy/blog/lwuit/BasicForm

    In the setting I have the external jar and the order/export as stated in http://jimmod.com/blog/wp-content/uploads/2010/04/Properties-Order-and-Export.png

    In addition if I want to create the package I obtain:

    Errors occurred during the build.
    Errors running builder ‘Preverification’ on project ‘test’.
    org.eclipse.jdt.internal.core.JavaModel.getTarget(Lorg/eclipse/core/resources/IContainer;Lorg/eclipse/core/runtime/IPath;Z)Ljava/lang/Object;

    Where does it come from?

    Thanks

    Chris

  • N.Ramesh

    Sir,I have code for filebrowser in j2me,this is in lcdui but i want lwuit,i tried like properties and add jar of lwuit but no use,can u tell how to change that code. I am waiting for u r replay

  • KIKEMORA

    UN FAVOR SERA QUE PUEDAS SUBIR UN EJEMPLO CON CALENDAR.. POR FA

  • jimmy

    @chris:
    For normal J2me project do you have problem building it?
    It seems like it’s j2me device configuration issue.
    What WTK version do you used?

  • Erick

    Sir, Please upload a code for adding a textfield to above “BasicForm.java”………. i’hv tried to add a textfield to the above code…..but whenever I run the project the emulator is flashed on screen and then disappear again…

  • jimmy

    @Erick:
    What’s the error in your IDE console?
    It should show exception if the application is stopped/error

  • Arpit Mithal

    java.lang.NullPointerException: 0
    at com.sun.lwuit.Display.getResourceAsStream(Display.java:1665)
    at com.sun.lwuit.util.Resources.open(Resources.java:448)
    at hello.HelloMIDlet.startApp(HelloMIDlet.java:768)
    at javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
    at com.sun.midp.midlet.MIDletPeer.startApp(), bci=7
    at com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=269
    at com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
    at com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
    at com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
    at com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26

    For above issue ensure the Theme name is correct. This name is case-sensitive. And remember .res filename and theme name may be different

  • Giorgio

    Hi Jimmy
    I just installed Pulsar, I followed you tutorial, but at tha first compilation I see 2 preverification error on LWUIT.jar 1.4, with empty description. The compiler compliance level is 1.4. I attached to pulsar the Java Micro Edition SDK 3.0. Can I find some where for further details?
    Thank you

  • Bhavesh

    I have a simple LWUIT theme created with Resource Editor in my src folder. I have included it in my .java but the theme doesn’t load up. It just shows its default black and white theme.
    Here is my code:
    http://pastebin.com/Z3×1xqza
    I am trying to apply LWUIT theme from last one week :(

  • jimmy

    @Arpit:
    Make sure you already copy file ‘LWUITtheme.res’ to your res folder

    @Giorgio:
    When I test with JME SDK 3.0 I also experience samething.
    I still not sure what the solution.
    For now I think let’s use Sun WTK 2.5.x

    @Bhavesh:
    I think the issue is on your theme file, make sure the theme filename you created is the same with the one in the code (Theme.res)
    If yes possible error theme file (maybe?)

  • Bhavesh

    @jimmy :
    Here is my Theme.res file’s folder location pic http://i.imgur.com/DReM0.png
    and here is my theme : http://www.box.net/shared/12dzaliohergq5px91e7
    Also could you send me any theme file which you have used so that I could assure that my method of applying theme is correct and there is some error in theme itself?

  • jimmy

    @Bhavesh:
    I test your theme file, and it’s only showing black & white theme.
    Then I try to open you theme file using ResourceEditor (which included in LWUIT/util), and receiving error on opening the theme file.
    So I think the problem is in your theme file, how do you create it?
    You can test with working theme file from the LWUIT which located at \LWUIT-Makeover\src\LWUITtheme.res
    I upload it to http://www.filesonic.com/file/1277423951/LWUITtheme.res

  • Giorgio

    @Jimmy Extactly what I’ve done. Many thanks ;)

  • Bhavesh

    @jimmy
    Thank you for your file :D
    Atlast I could apply a theme. The problem was I was using an older version of LWUIT.jar I downloaded the latest LWUIT 1.4.zip package and your theme worked! I made that theme with the latest LWUIT resource editor, its still not working on LWUIT 1.4. Now the Resource editor in LWUIT 1.4.zip works perfectly but I am also trying the new one.

  • ali hasani

    hi buddy
    i’m having a big problem with “List” component in LWUIT. i can’t assign command to the list items.
    would u plz help me?!
    Thanks & Regards.

  • jimmy

    @Ali:
    Have you set the listener using addActionListener() and setCommandList() ?

  • ali hasani

    hello world!!
    Bravooo
    actually you just gave me a hint, But it was enough!
    so Thanks a lot bro because this make my day great.

  • ali hasani

    hi
    i have created a sample app with netbeans (and of course Lwuit library). it almost works well, but

    there’s a problem!
    it has three forms:
    MainForm //(main form with list component which contains two links to Form1 & Form2)
    Form2 //(a form with a list component)
    Form3 //(an empty form!)
    the problem is, if i go to Form2 from MainForm and then comeback to MainForm again, at this time if i

    want to switch to Form2 again, i’ll receive an error BUT in the same situation i can switch between

    MainForm and Form3(which is empty) as many as i want! without any problem.

    here’s the error:
    an internal application error occurred:
    java.lang.lllegalArgumentException: Component is already contained in container: h[x=0 y=23

    width=240 height=261,layout = a,scrollableX = false, scrollableY =true, components = [ao]]

    so…
    please help me sir!
    Thanks & Regards.

  • jimmy

    @Ali:
    If you can give a full exception error trace or the source code, it will easier to guess the error cause.

    So far I’m guessing there’s add component function in the command listener when switching from MainForm to Form2. At first call it’s not causing error because the component is not yet added to container, but when it’s called again it causing error.

  • ali

    yes, you are right sir.
    i had put list in SrartApp while the form which contains the list was in the “case” command. so i put the list in the case command & problem was solved!
    thank you very much.

  • Don

    I big thanks for this sample. but I tried it and consistently get this errors. Which version of Lwuit did you use. Am using 1.4. (Please add a working mail address)

    java.io.IOException: Corrupt theme file unrecognized magic number: ff
    – az.a(), bci=308
    – az.(), bci=28
    – az.a(), bci=13
    – GOLD2.GOLD2.startApp(), bci=2
    – javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
    – com.sun.midp.midlet.MIDletPeer.startApp(), bci=7
    – com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=269
    – com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
    – com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
    – com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
    – com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26
    TRACE: , startApp threw an Exception
    java.lang.IllegalStateException: Layout doesn’t support adding with arguments: bk
    – bm.a(), bci=29
    – j.a(), bci=7
    – be.a(), bci=6
    – GOLD2.GOLD2.startApp(), bci=69
    – javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
    – com.sun.midp.midlet.MIDletPeer.startApp(), bci=7
    – com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=269
    – com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
    – com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
    – com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
    – com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26
    java.lang.IllegalStateException: Layout doesn’t support adding with arguments: bk
    – bm.a(), bci=29
    – j.a(), bci=7
    – be.a(), bci=6
    – GOLD2.GOLD2.startApp(), bci=69
    – javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
    – com.sun.midp.midlet.MIDletPeer.startApp(), bci=7
    – com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=269
    – com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
    – com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
    – com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
    – com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26

  • jimmy

    @Don:
    You’re welcome. Glad you find this article useful.

    I’m using LWUIT v1.3 since that the latest LWUIT version when this article wrote.

    From your error I’m guessing possible error with the themes file. Maybe because you using my theme file which is older version.
    Try to use LWUITtheme.res from LWUIT v1.4

  • ali hasani

    hi buddy
    canvas is bugging me!
    my project includes one Midlet & one Canvas
    all forms & components in the Midlet have created by lwuit, but the canvas

    has created without using any special library, i’d better to say it’s written by

    LCDUI and both have separate command listener
    btw, my problem is when i want to add Back command to the canvas,

    IN Emulator: makes a Menu(which i dont need it) in the place of right

    SoftButton and put the back command in the menu, while i have just ONE

    Command.

    IN CellPHone: show No commands! but when i click the fire key, it works and

    switch to the main form.
    i want the app to just have one command without menu, no difference the

    position of that(right,center or left)!

    what should i do,boss?
    thanks in advace
    regards

  • jimmy

    @Ali:
    If you use Canvas and don’t want to use it default command implementation (that can be different between phone; from my experience) you will need to implement your own.
    The idea is drawing your own button and capture the user action from keypress (don’t use addcommand to prevent any menu triggered).

    Hope I don’t miss understood your question.

  • ali hasani

    Thank you for quick reply.
    however my problem is somehow solved, but another one still last!
    is it possible to set a “command caption” for a fire key?
    i mean,i have a list component(created by lwuit). fire key works, i mean by

    pressing the fire key you can select & enter list items but it doesn’t have any

    caption, i tried to set command in the center(place of fire key) but it locates

    on place of left or right soft buttons.
    any solution?!
    thanks&regards

  • Cheyenne Menner

    Welcome, very interesting site. I am also leading one’s so I know how hard it is. Your articles are great, although not always I agree with them, but in spite of that I will visit your site more often. I wish you the success and the perseverance in running the site, Maria

Leave a Reply

Spam Protection by WP-SpamFree

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...