Saturday, September 25, 2010

FlowPanel - Children are added from right to left #-)

Hi,

I have realized a "button bar", i. e. a horizontal bar that contains
buttons, as a FlowPanel (not a HorizontalPanel, to be with standards
mode). The buttons are aligned to the right (float right).

However, when I add buttons, they are added from right to left, i. e.
the first one is at the right and the last one is at the left. I
expected that new widgets are appendet at the right?

I have tried a lot, but nothing changes the behavior.

Any ideas?

Magnus

----------

package myproject.commandbar;

import java.util.Iterator;

import com.google.gwt.dom.client.Style;
import com.google.gwt.event.dom.client.*;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.*;

public class CommandBar extends FlowPanel
{
private final FlowPanel pnl = new FlowPanel ();
private final HTML txt = new HTML ();
private ClickHandler hdl = null;

public CommandBar ()
{
super ();
init ();
}

private void init ()
{
this.add (txt);
this.add (pnl);

Style s = txt.getElement().getStyle ();
s.setFloat (Style.Float.LEFT);

s = pnl.getElement().getStyle ();
s.setFloat (Style.Float.RIGHT);

txt.setHTML(" ");
}

public void add (String lbl,int cmd)
{
Command c = new Command(prc,cmd);
add (lbl,c);
}

public void add (String lbl,Command cmd)
{
PushButton btn = new CommandPushButton (lbl,cmd);

btn.getElement().getStyle().setFloat (Style.Float.RIGHT);

pnl.add(btn);
}

public void setText (String txt)
{
this.txt.setText (txt);
}

}

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
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