with the following code sample, in the Design mode of SubClass.java, it only show a empty absolute panel.
AbstractSuperClass.java
- Code: Select all
package test.client;
import com.google.gwt.user.client.ui.Composite;
public abstract class AbstractSuperClass extends Composite {
public AbstractSuperClass() {
init();
show();
}
protected void init() {
}
public void show() {
}
}
SubClass.java
- Code: Select all
package test.client;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Label;
public class SubClass extends AbstractSuperClass {
private AbsolutePanel absolutePanel;
private Label lengthLabel;
// public SubClass() {
// init();
// show();
// }
protected void init() {
super.init();
absolutePanel = new AbsolutePanel();
initWidget(absolutePanel);
lengthLabel = new Label("Length");
}
public void show() {
absolutePanel.setStyleName("test");
absolutePanel.setSize("200px", "200px");
absolutePanel.add(lengthLabel, 10, 22);
}
}
However, if i remove the comment of the SubClass(), the design view shows the "Length" label in the absolute panel correctly.
To my understanding, java always calls its super() constructor but i don't know why i must explicity call the init() and show() explicitly in the SubClass constructor.
This behavior of GWTDesigner restrict the possibility of inheriting a superclass because the init() and show() will be call twice or even more in runtime.