Java 在UiBinder中的标签旁边显示我的星号
一天前我问了一个问题,关于我想放在带有文本的标签旁边的星号的名称和图像。然而,该图像显示了两次,我仍然在努力掌握这一点,因为我仍然在学习UiBinder和GwtJava 在UiBinder中的标签旁边显示我的星号,java,gwt,uibinder,Java,Gwt,Uibinder,一天前我问了一个问题,关于我想放在带有文本的标签旁边的星号的名称和图像。然而,该图像显示了两次,我仍然在努力掌握这一点,因为我仍然在学习UiBinder和Gwt <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> @mySprite.mySpriteClass{gwt image:“imageAccessor”;other:property;} .必须 { gwt图像:“requir
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
@mySprite.mySpriteClass{gwt image:“imageAccessor”;other:property;}
.必须
{
gwt图像:“requiredImage”;
宽度:7px;
高度:14px;
}
.需要实验室
{
颜色:303030;
字体系列:塔荷马,日内瓦,无衬线;
字号:10pt;
字体风格:普通;
字体重量:较轻;
}
如果我删除以下行
<ui:image field="requiredImage" src="images/required_indicator.gif"/>
如何在java文件中进行更改以正确显示星号图像
这是java文件
public class IndicatorLabel extends Composite implements HasText {
public interface Binder extends UiBinder<Widget, IndicatorLabel> {
}
private static final Binder binder = GWT.create(Binder.class);
public interface Style extends CssResource {
String required();
}
@UiField Style style;
@UiField Label label;
public IndicatorLabel() {
initWidget(binder.createAndBindUi(this));
}
public IndicatorLabel(String text) {
this();
setText(text);
}
公共类指示符标签扩展了复合实现HasText{
公共接口绑定器扩展了UiBinder{
}
私有静态最终绑定器Binder=GWT.create(Binder.class);
公共接口样式扩展了CssResource{
字符串required();
}
@尤菲尔德风格;
@UiField标签;
公共指示符标签(){
initWidget(binder.createAndBindUi(this));
}
公共指示符标签(字符串文本){
这个();
setText(文本);
}
亲切问候如果您只想显示一个不可点击的图像,更好的答案是只使用CSS来设置标签样式:
@sprite .requiredField
{
gwt-image: 'required';
background-repeat: no-repeat;
height: 12px;
width: 150px;
background-position: right top;
padding-right:10px;
}
但在任何情况下,您都应该在ResourceBundle上以不同的方式定义映像,如下所示:
@Source("save.png")
public ImageResource required();
您甚至不需要为此使用UIBinder,但如果您的目标是学习它,我建议您尝试更密切地遵循此文档:
@Source("save.png")
public ImageResource required();