×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Jun 2013
    Posts
    20

    Changing the way Lwuit menu look

    Hi I'm developing using Lwuit 1.5
    When I add commands to lwuit menu its set the command beside each other (each command in a box) and it doesn't show all the text on the command when it is larger then the command size
    so what I want is how to arrange the menu command as like a list (each command in a single row) and not beside each other
    So could anybody help me with that
    & Thanks in advance

  2. #2
    Registered User
    Join Date
    Dec 2012
    Location
    India
    Posts
    264

    Re: Changing the way Lwuit menu look

    Use this : Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_SOFTKEY);

    More info : http://lwuit.blogspot.in/2009/11/opt...for-touch.html

    Note : The method given in the article is deprecated.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Hamburg, Germany
    Posts
    280

    Re: Changing the way Lwuit menu look

    I also just fighting with an old LWUIT-App, and I also just found the Display.setCommandBehavior() method.

    My command where not visible at all on Asha501.
    The reason was that I had set

    Code:
    Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_TOUCH_MENU);
    This used to put the menu items in a table with two rows. It was easier to touch the orginal lwuit-behaviour.
    But it still does not look native. And on Asha 501, I don't see the menu at all.

    I found that when I use

    Code:
    Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_NATIVE);
    It shows the same behaviour as LCUID-Midlets on Asha 501:
    there are a few "bars" at the bottom, which you can drag. Than you see the menu with all your commands.

    There are other Constants you can try in the Display class,
    you can look the up in the javadocs

    Regards

    Karsten Meier

  4. #4
    Registered User
    Join Date
    Jun 2013
    Posts
    20

    Re: Changing the way Lwuit menu look

    Yes it works just fine
    Thank you very much

  5. #5
    Registered User
    Join Date
    Jun 2013
    Posts
    20

    Re: Changing the way Lwuit menu look

    I had another 2 question about the menu that rise:
    1) when I add commands to a menu & I add exit command (I set it as back command in order that it will be shown on the right of the menu) the problem is that it take the last command added to the menu and set it to be shown as the right of the menu & it appears in the menu too
    the code is that:
    cmd1= new Command((String) local.get("options"));

    f.addCommand(cmd1, 0);

    cmd2= new Command((String) local.get("help"));

    f.addCommand(cmd2, 1);

    exit= new Command((String) local.get("exit"));

    f.setBackCommand(exit);
    the problem is that the exit command doesn't appear at all & the cmd2 command appear in the right of the menu & in the menu too
    so what should I do

    2) the 2 nd question is that with every command I use the localize in order that it will appear in different language (and it works fine) but the question is how to do that with the command menu that the lwuit add it automaticly & with the cancel & select command that appear automatic when we press on the menu command?

    & Thanks in advance

  6. #6
    Registered User
    Join Date
    Dec 2012
    Location
    India
    Posts
    264

    Re: Changing the way Lwuit menu look

    This is how LWUIT works.You need to add exit command as well.Setting it as back command alone is not enough.

    This maybe of use to you : http://javakenai-dev.cognisync.net/f...and-rhs-menu-0

  7. #7
    Registered User
    Join Date
    Jun 2013
    Posts
    20

    Re: Changing the way Lwuit menu look

    Thank u so much Arunkam
    I followed your link and it gives a logical solution that I'm sure that it will work
    but it seems there is an error in it, the code is:
    public class CustomForm extends Form {

    /** OVERRIDE of the method in Form. We chop off the last command
    * in the Vector when making a menu list (and we do it to a copy!), because
    * the last item
    * is just a repeat of the LHS soft command, and it is placed
    * normally AFTER the last soft command on the RHS menu -- but
    * we want Exit to be the last command!
    *
    */
    protected Component createCommandComponent(Vector commandsIn) {

    int numCommands = commandsIn.size() - 1;
    Vector commands = new Vector(numCommands);
    for (int i = 0; i < numCommands; i++) {
    commands.addElement(commandsIn.elementAt(i));
    }
    commands);
    return super.createCommandComponent(commands);
    }

    specially in the commands); line so I erase it & also the super keyword cause method not found problem so I erase it too
    and i add a vector to customform type & there is no compile error
    but where I run the app there is the java lang illegal argument exception so what could I do?

    also how could I change the text of commands : menu , select & cancel that are shown automatically and the text remain in English though i'm doing a localization & it works just fine with every components else
    & Thanks a lot

  8. #8
    Registered User
    Join Date
    Jun 2013
    Posts
    20

    Re: Changing the way Lwuit menu look

    I think of a solution which work on the appearance of the menu only which is:
    changing the text of the soft button with the next code
    f.getSoftButton(0).setText((String) local.get("exit"));
    so it will look to the user as if the right soft button is different from the last command in the menu.
    but what I need now is a way that tells me when the user click on the right softbutton & when he click on the last command in the menu in order to do some different actions
    So could anybody help me please with that?

  9. #9
    Registered User
    Join Date
    Mar 2013
    Location
    Nasik, India
    Posts
    21

    Re: Changing the way Lwuit menu look

    I have also come across the same issue.. Below thigns did the trick for me.
    1) Add only two commands (Menu, Exit).
    2) On Menu click display a dialog box containing buttons (lwuit buttons places one in each row). (Y Box Layout)

    It was simple and effective.

    Thanks
    Vishal

  10. #10
    Registered User
    Join Date
    Jun 2013
    Posts
    20

    Re: Changing the way Lwuit menu look

    Thank you very much Vishal for your suggestion
    but I also wonder how to change the text of select & cancel command I tried to override the form class with the next code:
    public class fr extends Form {


    protected Command createMenuCancelCommand(Command a){
    Command b = new Command((String) local.get("cancel"));
    return createMenuCancelCommand(b);
    }

    }
    and then I declare my form with the type fr
    but it didn't work
    so is there any suggestion about that issue

    So could you please help me with that
    & Thank you very much

Similar Threads

  1. Menu Bar LWUIT
    By Budiv1 in forum Mobile Java General
    Replies: 0
    Last Post: 2013-04-30, 04:06
  2. Lwuit - Composite Menu / Command ?
    By dhbellol in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2013-04-17, 10:50
  3. Customize lwuit Menu bar
    By Dev.Reham in forum Mobile Java General
    Replies: 0
    Last Post: 2012-10-19, 11:47
  4. LWUIT Increasing size of menu bar
    By vishal.vpb in forum Mobile Java General
    Replies: 1
    Last Post: 2012-01-06, 06:41
  5. Context Menu in J2ME (LWUIT)
    By sandeepkumar03 in forum Mobile Java General
    Replies: 0
    Last Post: 2009-01-12, 09:41

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •