SOLVED how to Put a GWTPanel into a html <div></div>

21 views
Skip to first unread message

Lindomir Avelar

unread,
Oct 23, 2011, 7:47:31 AM10/23/11
to Google Web Toolkit
Hi guys! I solved a trouble a I need to broadcast it!!

First you need to put a <div tag> with a ID like this in your html
code
<div id="main">
</div>

Second in your ImageViewer.java you have to add a VerticalPanel (you
can use GWT designer it is very easy) see the code below


public class ImageViewer implements EntryPoint {
private VerticalPanel VLayout;
private TabPanel tabPanel;
private Button btnNewButton;
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();
rootPanel.setSize("800", "600");
rootPanel.add(getVLayout(), 156, 52);

THIS IS THE MAGIC I AM PUTING ALL MY VLayout INTO MY
HTML DIV
RootPanel.get("main").add(VLayout);
}
private VerticalPanel getVLayout() {
if (VLayout == null) {
VLayout = new VerticalPanel();
VLayout.setSize("340px", "221px");
VLayout.add(getTabPanel());
}
return VLayout;
}
private TabPanel getTabPanel() {
if (tabPanel == null) {
tabPanel = new TabPanel();
tabPanel.setSize("287px", "169px");
tabPanel.add(getBtnNewButton(), "New tab", false);
}
return tabPanel;
}
private Button getBtnNewButton() {
if (btnNewButton == null) {
btnNewButton = new Button("New button");
btnNewButton.setSize("104px", "33px");
}
return btnNewButton;
}
}

I am a begginer but it was very hard to me discovery that!! Thank you
every one guys

Thomas Broyer

unread,
Oct 23, 2011, 12:29:28 PM10/23/11
to google-we...@googlegroups.com
How is that different from RootPanel.get("main").add(getVLayout()) ? (or maybe RootPanel.get("main").add(getVLayout(), 156, 52), I never use absolute positionning so I don't know how it works when you move your VLayout from RootPanel.get() to RootPanel.get("main"))

Did I miss anything?

Patrick Tucker

unread,
Oct 25, 2011, 10:47:48 AM10/25/11
to Google Web Toolkit
Looks like the only difference would be that he ends up setting the
body element, which is retrieved with get(), to 800 x 600. Other than
the extra work of moving VLayout from the body element to the "main"
element.
Reply all
Reply to author
Forward
0 new messages