tags:

views:

27

answers:

1

Hi to everybody :)

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

A: 

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.

z00bs
For more information feel free to ask :)
z00bs
thanks for the reply. Ah so the label class create a div? Nice. But if i create 2 label for example (label1 and label2) and i need to add label2 into label1 how can do it? The method .add is not avaiable on label methods.
markzzz
`Labels` are meant to be used to display some text in a `<div>`, if you want to have a `<div>` to add other elements to you want a `Panel`. Try `SimplePanel`
Jason Hall
ah ok! Clear :) So in HTML what corrispond the Label class? a table? a span? simple text? Should be nice to see the generated HTML :)
markzzz
last thing : with this metodology, i see that i can't add 2 element on the same div. For example, if my header, header1 and header2 are SimplePanel, i can't do header.add(header1); header.add(header2); Why?
markzzz
of course you can. Have a look at `FlowPanel` or `HTMLPanel`.
z00bs
to your previous comment: a div corresponds to a `Label`, a span to a `InlineLabel`. To check out the generated HTML run your app in dev mode and use for example FireBug or the like to inspect the document.
z00bs
thanks to both :) You really help me!!!! Should be nice have a list of class with definition about what they do :)
markzzz
google for gwt api.
z00bs
uhm yeah. In fact whis http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/index.html?overview-summary.html should help me :) Thanks again!!!
markzzz