在GWT中,创建一个使用"at"元素的自定义AbsolutePanel,可以通过以下步骤实现:
CustomAbsolutePanel
。CustomAbsolutePanel
类中,继承AbsolutePanel
类,并添加一个新的属性,例如at
元素。import com.google.gwt.user.client.ui.AbsolutePanel;
public class CustomAbsolutePanel extends AbsolutePanel {
private String at;
public void setAt(String at) {
this.at = at;
}
public String getAt() {
return at;
}
}
CustomAbsolutePanel
实例,并设置其at
属性。<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:style>
.customAbsolutePanel {
background-color: #f5f5f5;
border: 1px solid #ddd;
padding: 10px;
}
</ui:style>
<g:HTMLPanel>
<g:CustomAbsolutePanel addStyleNames="{style.customAbsolutePanel}" at="customAtValue">
<!-- Add your widgets here -->
</g:CustomAbsolutePanel>
</g:HTMLPanel>
</ui:UiBinder>
CustomAbsolutePanel
实例,并使用其at
属性。CustomAbsolutePanel customAbsolutePanel = (CustomAbsolutePanel) yourUiBinder.createAndBindUi();
String atValue = customAbsolutePanel.getAt();
现在,你已经成功创建了一个使用"at"元素的自定义AbsolutePanel。你可以根据需要修改CustomAbsolutePanel
类,以添加更多的属性和方法。
领取专属 10元无门槛券
手把手带您无忧上云