Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    StaticTextItem width and value alignment

    Hi,

    I am using SmartGWT 2.5.

    I have an issue with alignment of the value of a StaticTextItem when placed in ToolStrip. I use following code:

    Code:
    public class MainMenu extends ToolStrip {
    
    	public MainMenu() {
    		setWidth100();
    		setHeight("30px");
    		setMembersMargin(5);
    
    		//push all members to the right
    		addFill();
    
    		StaticTextItem loggedAsLabel = new StaticTextItem("loggedAs", "Logged as");
    		loggedAsLabel.setHeight("30px");
    		loggedAsLabel.setWidth("300px");
    		loggedAsLabel.setValue("some name");
    		//loggedAsLabel.setTextAlign(Alignment.LEFT);
    		addFormItem(loggedAsLabel);
    
    		ToolStripButton logoutButton = new ToolStripButton("Logout");
    		addButton(logoutButton);
    	}
    
    }
    I can see actually 2 issues in the result of this code:
    1) the text is 'user' is not alligned with the StaticTextItem label 'Logged as' (see incorrectAlignment.jpeg)
    2) the width on the StaticTextItem applies only to the 'label' part of it and makes longer text wrapped (see widthOnlyOnLabelField.jpeg) (I could live with this)

    At least it seems that if there is no space character the 'value' part of StaticTextItem gets more space (see longUserNameWithoutSpaceCharacter.jpeg) though I still do not like the alignment.
    Attached Files

    #2
    As a result of my effort I would like to have a static text on ToolStrip.
    Am I trying to use incorrect component for what I want to achieve? Is there a better component than StaticTextItem for this purpose?

    Thanks

    Comment


      #3
      Any solution?

      Was this ever resolved? I was looking to just put some text left aligned on the ToolStrip but the words are wrapping.

      Comment


        #4
        You should be able to use the APIs 'setWrapTitle' and 'setWrap' on an item to enable / suppress wrapping of the item's title or value.
        A couple of other notes on the original posting:
        When specifying pixel width/height values for components and FormItems, you should pass in an integer rather than a string.
        Also for greater control over the form's appearance within a toolstrip you can always define the form explicitly and add it via 'addMember()' rather than using the special "addFormItem" API.

        If you still have trouble getting the appearance you're after, we'd recommend you show us exactly what you're trying to achieve and what's failing to work - preferable with a little test-case we can run to demonstrate the problems you're facing

        Thanks
        Isomorphic Software

        Comment

        Working...
        X