Java gwt flowpanel always newline

I am trying to use flowpanel in java gwt, but when I add different widgets, the panel adds each widget on a new line, this is how I set the flowPanel

 public class Test extends Composite {
   public abstract class SomeWidget<T> extends Composite {
      ...
   }

   public class SomeStringWidget extends SomeWidget<String> {
      ...
   }


   public void setWidget() {
     FlowPanel fp = new FlowPanel();
     fp.setWidth("100%");
     fp.add(new SomeStringWidget());
     fp.add(new SomeStringWidget());
     ...
   }
 }

      

Why is each widget given on a new line, and not like a streaming bar, has to add widgets on a line until there is more space and then add them on a new line?

+3


source to share


3 answers


I ran into the same problem and styled the FlowPanel checkbox to align the widgets in a row. This will solve your problem.

FlowPanel fp = new FlowPanel();
fp.setStyleName("flowPanel_inline");

      

style.css



.flowPanel_inline
{
    display:inline;
}

      

Also, you must set the same style in the added elements.

+3


source


The flow panel generates a DIV with the GWT-FlowPanel style. If you want your inner widgets to be inline, do the CSS for the inner widgets with the following CSS:

.SomeStringWidget {
   display: inline;
}

      

or

.SomeStringWidget {
    display: inline-block; 
}

      



or

.SomeStringWidget {
   float: left;
}

      

And in your widget set the .SomeStringWidget CSS class to constuctor.

public SomeStringWidget {
    this.setStyleName("SomeStringWidget");
}

      

+7


source


If your SomeStringWidget is a shortcut it will always be a newline. If you don't want to use a newline, use InlineLabel.

0


source







All Articles