Am Montag, 3. September 2012 14:08:27 UTC+2 schrieb Andrei:
Maybe if you can give a specific example of a problem you face, we can suggest a solution.
Hello,
I actually need a composite panel "TournamentField" that consists of two widgets, a label and a button at the right of the label. I want that the label always consumes most available horizontal space, while the button has a fixed size.
[ label with variable width][button]
Below is the code.
(The HorizontalLayoutPanel is just a FlowPanel which sets "float:left;" on its children, as supposed by the article "Moving to standards mode" in the GWT docs.
As you can see, I even needed to use a hard coded size for the height of the label, because I do not know the default height...
This TournamentField is added to a LayoutPanel.
Magnus
-----
package bcs.client.mod.tournament.cmp;
...
public class TournamentField extends Composite implements RequiresResize
{
private HorizontalLayoutPanel pnl = new HorizontalLayoutPanel ();
private Label lbl_Tournament = new Label ();
private PushButton btn_Select = new PushButton (">");
{
private HorizontalLayoutPanel pnl = new HorizontalLayoutPanel ();
private Label lbl_Tournament = new Label ();
private PushButton btn_Select = new PushButton (">");
private static final int XS_BTN = 15;
private static final int YS = 25;
public TournamentField ()
{
super ();
init ();
}
private void init ()
{
initWidget (pnl);
private static final int YS = 25;
public TournamentField ()
{
super ();
init ();
}
private void init ()
{
initWidget (pnl);
pnl.add (lbl_Tournament);
pnl.add (btn_Select);
pnl.add (btn_Select);
gui.styleBorder(lbl_Tournament,"#FF55DD");
}
@Override
public void onResize()
{
Size sp = gui.getSize(pnl); // size contains two ints: x and y
}
@Override
public void onResize()
{
Size sp = gui.getSize(pnl); // size contains two ints: x and y
btn_Select.setWidth(XS_BTN + "px");
int lxs = sp.x - XS_BTN - 15;
if (lxs < 0)
lxs = 0;
lbl_Tournament.setWidth(lxs + "px");
lbl_Tournament.setHeight(sp.y + "px");
}
}
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/i-wyA61GKYoJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment