How to size a widget for optimal presentation?

61 views
Skip to first unread message

Magnus

unread,
Aug 28, 2012, 8:09:42 AM8/28/12
to google-we...@googlegroups.com
Hello,

I have a Widget "SelectionField", which extends Composite and contains a label and a button, within a HorizontalPanel.

The label should always occupy all the horizontal space that is available besides the button.

I tried to set its width to "100%". I also tried around with RequiresResize and onResize, but nothing worked.

How would you do this?

Thanks
Magnus

-----


public class SelectionField extends Composite implements
{
 private HorizontalPanel pnl = new HorizontalPanel ();
 private Label           lbl_Tournament = new Label ();
 private PushButton      btn_Select = new PushButton (">");
 
 public SelectionField()
 {
  super ();
 
  initWidget (pnl);

  pnl.setBorderWidth(1);
  pnl.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
 
  pnl.add (lbl_Tournament);
  pnl.add (btn_Select);

  lbl_Tournament.setWidth("200px");
 }
}

Jens

unread,
Aug 28, 2012, 9:47:18 AM8/28/12
to google-we...@googlegroups.com
First

pnl.setWidth("100%");

and instead of lbl_Tournament.setWidth("200px") I think you should do pnl.setCellWidth(btn_Select, "50px"); btn_Select.setWidth("100%");

This should limit the cell that contains the button to fixed 50px width and as you have not specified any width for the label cell and the label itself it should take the remaining space.

-- J.

Magnus

unread,
Aug 30, 2012, 9:18:05 AM8/30/12
to google-we...@googlegroups.com
Hm,

this showed no effect...

Magnus
Reply all
Reply to author
Forward
0 new messages