×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    25

    LWUIT: Button Text Alignment CENTER jump to LEFT when selected

    Hello All,

    I am using LWUIT for the Series 40 below.

    http://projects.developer.nokia.com/LWUIT_for_Series_40

    I am using the S40-no-themes.jar.

    I have the sample code below. The problem, I'm having is when I select the "Hello" button, the text will jump to LEFT. Can anyone help me. Thanks in advance.

    Code:
    import javax.microedition.midlet.*;
    
    import com.sun.lwuit.*;
    import com.sun.lwuit.events.*;
    import com.sun.lwuit.layouts.BoxLayout;
    
    public class HelloWorld extends MIDlet implements ActionListener {
        public void startApp() {
          Display.init(this);
    
          Form f = new Form("Hello, LWUIT!");
          f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
          Button hello = new Button("Hello");
          hello.getStyle().setAlignment(Component.CENTER);
          hello.getSelectedStyle().setAlignment(Component.CENTER);
          f.addComponent(hello);
          f.show();
          
          Command exitCommand = new Command("Exit");
          f.addCommand(exitCommand);
          f.addCommandListener(this);
        }
    
        public void pauseApp() {}
    
        public void destroyApp(boolean unconditional) {}
    
        public void actionPerformed(ActionEvent ae) {
          notifyDestroyed();
        }
    }

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,738

    Re: LWUIT: Button Text Alignment CENTER jump to LEFT when selected

    I do not know LWUIT, but according to the docs there might be a getPressedStyle too.

  3. #3
    Registered User
    Join Date
    Jul 2012
    Posts
    25

    Re: LWUIT: Button Text Alignment CENTER jump to LEFT when selected

    Quote Originally Posted by wizard_hu_ View Post
    I do not know LWUIT, but according to the docs there might be a getPressedStyle too.
    Thanks, I used "getPressedStyle" and it works now.
    I am wondering what does getSelectedStyle() mean then.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,738

    Re: LWUIT: Button Text Alignment CENTER jump to LEFT when selected

    Well, I really do not know LWUIT. Just checked the docs, exactly because getSelectedStyle looked suspicious. I think it may have something to do with focusing. For example if the device has no touchscreen so the user navigates between the controls with a joypad. I can imagine that this SelectedStyle is applied to show the current control. But still, this is just a guess, I have not used LWUIT.

  5. #5
    Registered User
    Join Date
    Jul 2012
    Posts
    25

    Re: LWUIT: Button Text Alignment CENTER jump to LEFT when selected

    Thanks. This makes sense.

  6. #6
    Nokia Developer Expert
    Join Date
    May 2012
    Location
    Espoo
    Posts
    224

    Re: LWUIT: Button Text Alignment CENTER jump to LEFT when selected

    getSelectedStyle() -- Returns the Component Style when it owns focus
    getPressedStyle()---Returns the Component Style when it is pressed


    You can’t see getSelectedStyle() in full touch devices(full touch devices don’t have focus), but it can easily visible in non-touch or Touch & Type devices.

    I tested following code in S40 SDK 1.1
    Button hello = new Button("Hello");
    hello.getStyle().setAlignment(Component.CENTER);
    hello.getSelectedStyle().setAlignment(Component.RIGHT);
    hello.getPressedStyle().setAlignment(Component.LEFT);
    getSelectedStyle() returns when touched the button
    getPressedStyle() returns when button is pressed and hold.

Similar Threads

  1. Replies: 2
    Last Post: 2012-01-03, 09:55
  2. Replies: 2
    Last Post: 2010-09-28, 07:41
  3. take the text of command on left to centre in lwuit
    By Manish_Bansal in forum Mobile Java General
    Replies: 3
    Last Post: 2010-07-08, 04:53
  4. Hide UNLOCK text on left button
    By polaris_1985 in forum Symbian User Interface
    Replies: 0
    Last Post: 2006-06-22, 08:53
  5. RichText + Right to Left text Alignment
    By chishti.hameed in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-07-20, 06:15

Posting Permissions

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