Hi!
I'm trying to make my class MenuHome as a container through the
abstract class com.google.gwt.user.client.ui.Composite.java but I
have always the same problem:
This widget's parent does not implement HasWidgets.
In the main class I want a panel that could contain all the widget
children (instances of other classes) and then be able to remove any
time a widget you do not have to see, perhaps with a command
vPanel2.clean()
When run my application, when I click on LOGIN shows this exception.
How could solve?
My code simplified:
-----MenuHome.java-------container
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.VerticalPanel;
public class MenuHome extends Composite {
private VerticalPanel vPanel;
private Login login;
public VerticalPanel vPanel2;
public MenuHome() {
super();
Command cmd = new Command(){
public void execute(){
vPanel2.clear();
}
};
Command cmdOpen = new Command(){
public void execute(){
if(vPanel2.getWidgetCount() == 0){
login = new Login();
vPanel2.add(login);
}
}
};
vPanel = new VerticalPanel();
MenuBar menu = new MenuBar();
vPanel2 = new VerticalPanel();
menu.addItem("HOME", cmd);
menu.addItem("LOGIN", cmdOpen);
vPanel.add(menu);
vPanel.add(vPanel2);
initWidget(vPanel);
}
protected void onAttach() {
super.onAttach();
}
}
------------------Login.java--------class child
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.gwtext.client.widgets.Button;
public class Login extends Composite{
MenuHome mhome = new MenuHome();
private VerticalPanel panelVert;
private Button loginButton;
public Login(){
panelVert = new VerticalPanel();
panelVert.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
panelVert.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
loginButton = new Button("Login");
panelVert.add(loginButton);
initWidget(panelVert);
mhome.vPanel2.add(panelVert); //<-----------------the error add
the
panel to the //main container of class MenuHome
}
}
-------------------------
Error
[ERROR] Uncaught exception escaped
java.lang.IllegalStateException: This widget's parent does not
implement HasWidgets
at com.google.gwt.user.client.ui.Widget.removeFromParent(Widget.java:
67)
at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:
77)
at com.google.gwt.user.client.ui.VerticalPanel.add(VerticalPanel.java:
53)
at com.gwt.client.Login.<init>(Login.java:55)
at com.gwt.client.MenuHome$2.execute(MenuHome.java:29)
at
com.google.gwt.user.client.CommandExecutor.doExecuteCommands(CommandExecutor.java:
311)
at com.google.gwt.user.client.CommandExecutor
$2.run(CommandExecutor.java:206)
at com.google.gwt.user.client.Timer.fireImpl(Timer.java:164)
at com.google.gwt.user.client.Timer.fireAndCatch(Timer.java:150)
at com.google.gwt.user.client.Timer.fire(Timer.java:142)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:
103)
at
com.google.gwt.dev.shell.moz.MethodDispatch.invoke(MethodDispatch.java:
80)
at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native
Method)
at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:
1428)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2840)
at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)
I hope someone can help me kindly.
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---