Skip to main content

how to add softbutton into container??

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
3 replies [Last post]
bayu.utomo
Offline
Joined: 2011-10-24

hi all,

sorry before if my english not good,

i'm newbie in LWUIT

i know to add a command into form, we use form.addcommand(), but i want to add command like in the form into container. How to add it?

i have tried a code like this :

Command prevCommand = new Command("Prev", 2);
Command sendCommand = new Command("Send", 3);

Container cont_menubar = new Container(new GridLayout(1, 4));

Button prevButton = new Button(prevCommand);
Button sendButton = new Button(sendCommand);

prevButton.addActionListener(this);
sendButton.addActionListener(this);

cont_menubar.addComponent(prevButton);
cont_menubar.addComponent(new Label());
cont_menubar.addComponent(new Label());
cont_menubar.addComponent(sendButton);

container.addComponent(BorderLayout.SOUTH, cont_menubar);

but it not success, the behavior not like softbutton in menubar in the form

thanks in advance

Bayu

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07

You add "softbutton" actions by using the addCommand(...) methods of form. See the LWUITDemo source code and the other demos within LWUIT.

bayu.utomo
Offline
Joined: 2011-10-24

yes i know that. If i use the addCommand(...) methods of form, then the button will appear in menubar of form, not in my container. But my application has requirement to add button directly to container and can receive action like "softbutton".

I have been searching in LWUIT API documentation, but couldn't get any help

please help me

thank you

vprise
Offline
Joined: 2003-11-07

You need to replace the menu bar class by setting your own menu bar in the look and feel and by doing that you can customize the behavior of the menu bar to pretty much anything.