Hi I am quite unsure if the spacing on top of the VerticalPanel widget in my app is a bug or not.
For simplicity, I have this kind of code:
public class MainWidget extends Composite {
private VerticalPanel mainPanel = new VerticalPanel();
public MainWidget() {
mainPanel.add(new Button("Test button"));
initWidget(mainPanel);
}
}
When run, the rendered view has this spacing on top of the widget inside the VerticalPanel, about the same height of the button, but not exactly that.
However, if I just put initWidget(new Button("Test)); the view is rendered properly which the spacing is gone and that the button fits exactly on the top-left of the browser's client area.
I've been struggling to fix this, I have tried DockPanel also but the result is the same.
Any ideas?
It appears that this bug is caused by a GWT framework I included in the project which causes this.
Related
I am developing a GWT Web application and I would like to include the resize capability into the container. For that, I am implementing a combination of Vertical and Horizontal Panels within a FlowPanel which is resizable. Well, the code for the resize method is the following:
Window.addResizeHandler(new ResizeHandler() {
#Override
public void onResize(ResizeEvent event) {
flowPanel.setHeight(event.getHeight()+"px");
flowPanel.setWidth(event.getWidth()+"px");
}
});
However, when I change the size of the windows, the size of the web elements does not change. Do you know how to implement it?
Thank you very much in advance!!!
You may want to review your layout solution. There are very few cases when you need to use a ResizeHandler. Typically, you can achieve a desired layout either by using a LayoutPanel (or Horizontal/Vertical panels) that automatically resize with the window, or by using CSS. Then your layout will respond well to any changes in a browser window, and you don't need to write any code for that to happen.
EDIT:
In order for a widget to resize automatically, the parent widget must implement ProvidesResize, and the child widget must implement Resizable. FlowPanel does not implement either. Once you use it, the chain of resizing events is broken.
Typically, I use a LayoutPanel for my outmost container. It occupies the entire browser window when added to the RootPanel, and it adjusts with the Window. Vertical and Horizontal panels are similar.
use,
window.getClientWidth();
window.getClientHeight();
Based on your component size you can -/+ px and use.
I'm using a PopupPanel but by default it cannot be dragged on the screen. Is the way to make id draggable or I should use whole another component?
The DialogBox class is draggable, by its title bar (which a PopupPanel doesn't have; also note that DialogBox extends DecoratedPopupPanel, not just PopupPanel, and sizing works differently than for PopupPanel).
Is it possible to add DockLayoutPanel inside another panel other than the RootLayoutPanel?
If so, how would you do it?
I attempted to add it inside HTMLPanel, and only north of the DockLayoutPanel shows.
Then I tried it inside LayoutPanel, it failed again.
I thought it would have work for LayoutPanel because RootLayoutPanel is a subclass of LayoutPanel.
Any answers welcome.
Thanks,
DockLayoutPanel is a RequiresResize widget, so either you put it inside a ProvidesResize widget (any so called layout panel) or you give it an explicit size.
See the Using a LayoutPanel without RootLayoutPanel section in http://code.google.com/webtoolkit/doc/latest/DevGuideUiPanels.html#Recipes
I'm trying to insert a gwt datagrid in my application. If i set a static height (500px) everything works nice. But i want to make the dataGrid auto adjust to screen size. With height 100% i get a blank screen.
i've also tried to put the datagrid into a resizeLayoutPanel with the same results.
any tips?
All RequiresResize widgets should be given an explicit size, or be added to ProvidesResize widgets (up to a RootLayoutPanel or a ProvidesResize widget with an explicit size; the only exception is ResizeLayoutPanel which doesn't implement ProvidesResize because it couldn't honor the contract for its header and footer widgets, but it definitely honors it for the center widget).
So the question is: where did you add your DataGrid and/or ResizeLayoutPanel?
Thomas Broyer is correct. Nonetheless I found something of interest concerning the DataGrid (it does not happen in CellTable).
If you are using a DeckPanel and if you are creating the DataGrid on a hidden Panel of this DeckPanel, than the data of the DataGrid will not be visible if you show the panel of the DataGrid.
I found only one workaround: call addDataDisplay of your DataProvider "after" the panel was made visible.
I have got a DisclourePanel with a button on it. But when I call button.getParent()
I always get a SimplePanel. With other Panel like VerticalPanel it works.
Does Anyone know why?
DisclosurePanel extends type Composite meaning it is a widget that can be composed of many widgets. It consists of a header and a SimplePanel both stacked in a VerticalPanel. Any content you give it, is placed in this SimplePanel, in your case a button, thus SimplePanel is returned by getParent()