markzzz
markzzz

Reputation: 47965

GWT - First Steps - Div+label+css style

Im starting making an application with GWT. Now, i use the AbsolutePanel widget to describe a "div". After this, i create a label (should be a span?), i add to this panel and i apply a css class to the div.

this is the code :

public void onModuleLoad() {
    AbsolutePanel contenitore = new AbsolutePanel();
    final Label label = new Label("Hello, GWT!!!");
    contenitore.setStyleName("contenitore");
    contenitore.add(label);

}

// css
body {background:#999999;}
.contenitore{ background-color:#333333; width:980px; margin-left:auto; margin-right:auto; overflow:auto;}

Unfortunatly, it don't get the css propiety of the div, and i cant see the label. Why? And, there are any change to see (im using the gwt debug on netbeans) which is the generated html code? cheers

Upvotes: 1

Views: 879

Answers (1)

z00bs
z00bs

Reputation: 7498

Some tips on your example:

  • add the AbsolutePanel to the RootPanel
RootPanel.get().add(contenitore);
  • the Label class creates a <div> element. If you're looking for a <span> check out InlineLabel

  • to see how to deal with css in GWT check this out or have a look at UiBinder

Hope that helps.

Upvotes: 1

Related Questions