Help With Commands,Alignment And Font Display

68 views
Skip to first unread message

Keen Student

unread,
Sep 25, 2013, 8:58:42 AM9/25/13
to codenameone...@googlegroups.com
I have an application  (already designed for android and blackberry) that i need to deploy to J2ME
devices. I had already started in LWUIT before discovering CN1 and deciding to use it.
My issues are three fold (FOR NOW):

a) How can i make a "Command" appear on the screen?...
tried this with netbeans..."public void start() {
        if(current != null){
            current.show();
            Command change2 = new Command("View Dialog") {
            public void actionPerformed(ActionEvent ev) {
                //mode = SideMenuMode.BOTH_SIDES;
                Dialog.show("Both","Dialog","ok",null);
            }
        };
    current.addCommand(change2);"
.....it compiled....but did not display the "View Dialog"..command.

b) How can i center a label?...
tried this in LWUIT..."label.setTextPosition(Label.CENTER);.....DID NOT WORK.


c)How to change font color and size of a label's text?
..I read that this has to do with the UUID..but in the GUI Builder in NETBEANS...i did not see any options for this.(and for the other questions asked above).


My apologies for these "naive" questions...i am coming from Android where all i had to do was use an XML file.
Willing to learn, just need a few pointers. Thanks.


Shai Almog

unread,
Sep 25, 2013, 11:03:24 AM9/25/13
to codenameone...@googlegroups.com
a) On which platform? For Android 2.x etc. you will need to press the menu button.

b) Use label.getUnselectedStyle().setAlignment(Component.CENTER) or customize the UIID in the designer.
Make sure you place the component in a BoxLayout.Y so it takes up all the available width. Otherwise it will be centered to a very narrow size.

c) In the designer tool you can just set the entry color. I suggest viewing the How Do I? on themeing.
You can also use x.getUnselectedStyle().setFgColor(...);

Keen Student

unread,
Sep 26, 2013, 4:51:44 AM9/26/13
to codenameone...@googlegroups.com
Thanks for your response. The platform is J2ME (Nokia..and other Java Feature phones)...as i mentioned.... i will like the command link to display on the form/screen. 

Shai Almog

unread,
Sep 26, 2013, 10:27:43 AM9/26/13
to codenameone...@googlegroups.com
If its a J2ME device such as Nokia etc. the command should appear under a menu softbutton in the bottom of the screen once you invoke addCommand. You can see that on our simulator.
Make sure that the form you are looking at is the same one in code.
Reply all
Reply to author
Forward
0 new messages