public class PopupMenu extends PopupPanel {
private Grid panel = new Grid();
public PopupMenu(){
panel.resize(3, 1);
panel.setWidget(0, 0, ...);
setStyleName("Popup-Panel");
setWidget(panel);
}
I've seen a workaround adding a HTML before the setWidget(panel)
but when I tried it, it only shows the HTML, not the widget.
<exception>
[ERROR] Uncaught exception escaped
java.lang.RuntimeException: JavaScript method
'@com.google.gwt.user.client.ui.impl.PopupImplIE6::setClassName(Lcom/google/gwt/user/client/Element;Ljava/lang/String;)'
threw an exception
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java:394)
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeVoid(ModuleSpaceIE6.java:283)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:127)
at
com.google.gwt.user.client.ui.impl.PopupImplIE6.setClassName(PopupImplIE6.java:39)
at
com.google.gwt.user.client.ui.PopupPanel.setStyleName(PopupPanel.java:194)
at idocs.pati.web.gwt.client.PopupMenu.<init>(PopupMenu.java:80)
at
idocs.pati.web.gwt.client.TableHeader$1.onClick(TableHeader.java:19)
at
com.google.gwt.user.client.ui.ClickListenerCollection.fireClick(ClickListenerCollection.java:36)
at
com.google.gwt.user.client.ui.Hyperlink.onBrowserEvent(Hyperlink.java:118)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:902)
Caused by: com.google.gwt.core.client.JavaScriptException: JavaScript
TypeError exception: 'children.1' is null or not an object
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at
com.google.gwt.dev.shell.ModuleSpace.createJavaScriptException(ModuleSpace.java:267)
at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.exceptionCaught(ModuleSpaceIE6.java:105)
at
com.google.gwt.dev.shell.JavaScriptHost.exceptionCaught(JavaScriptHost.java:31)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
com.google.gwt.dev.shell.StaticJavaDispatch.callMethod(StaticJavaDispatch.java:45)
</exception>
public void onModuleLoad() {
PopupPanel popup = new PopupPanel();
popup.setWidth("100px");
popup.setPopupPosition(200, 300);
RootPanel.get("popup").add(popup);
}
This sample threw an exception java.lang.RuntimeException: JavaScript
method
'@com.google.gwt.user.client.ui.impl.PopupImplIE6::setWidth(Lcom/google/gwt/user/client/Element;Ljava/lang/String;)'
threw an exception
PopupPanel hasn't childs so a Exception will be threw. The same
situation happens when you try to set position of a PopupPanel which
hasn't childs.
This is a strange behavior. Maybe this is a bug.
The next code will run perfectly.
public void onModuleLoad() {
PopupPanel popup = new PopupPanel();
popup.addWidget(new Label("Hello world GWT"));
popup.setWidth("100px");
popup.setPopupPosition(200, 300);
RootPanel.get("popup").add(popup);
}