Announcement

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

    Right align button

    I've been playing around with smartgwt for a while and one thing I haven't been able to figure out is how to right align a button. (Have a button be a certain distance from the right edge of its parent even when the parent gets resized). I've tried button.setRight(int); but it doesn't work.

    Any ideas?

    #2
    On way to do this would be setSnapTo("R") (or "TR" or "BR" for top or bottom alignment), with a negative left coordinate if desired (applies relative to the snapTo location).

    Another is to use a layout and set the alignment on the Layout, with possibly a LayoutSpacer before the button to be aligned.

    Best approach depends on the details of what other components are involved.

    Comment


      #3
      Fixed it

      Figured it out.

      If I wrap the button in a HLayout and set it to align right, then the button will be right aligned.

      Code:
      HLayout buttonArea = new HLayout();
      buttonArea.setAlign(Alignment.RIGHT);
      
      IButton loginButton = new IButton("Login");
      buttonArea.addMember(loginButton);

      Comment

      Working...
      X