Designing a label with images and text GWT


I am current trying to create tab that has a check mark when the I click done and then shows an an "X" when I click cancel. Currently I have my tab written in XML. I am wondering how I would go about implementing this. I am thinking about using two labels and combining them together. One will be in XML the other one will be in java only. I am also wondering how i would space these two so they over lap and act as one tab together.

我正在尝试创建当我单击完成时带有复选标记的选项卡,然后在单击取消时显示“X”。目前我的标签是用XML编写的。我想知道如何实现这一目标。我正在考虑使用两个标签并将它们组合在一起。一个将是XML,另一个将只在Java中。我也想知道如何将这两个空间放在一起,这样它们就可以在一起作为一个标签。

public class buttonclickers extends Composite {

private static buttonclickersUiBinder uiBinder = GWT
        .create(buttonclickersUiBinder.class);
@UiField PushButton button_1;
@UiField PushButton button_2;

interface buttonclickersUiBinder extends UiBinder<Widget, buttonclickers> {
}

public buttonclickers() {
    initWidget(uiBinder.createAndBindUi(this));
}

@UiHandler("button_1")
void onButton_1Click(ClickEvent event) {
    AppUtils.EVENT_BUS.fireEvent(new ButtonEvent());
}
@UiHandler("button_2")
void onButton_2Click(ClickEvent event) {
}
}

This is what I have so far. Is there anyway to change the image on these xml buttons when I press it? Any idea will help thank you!

这就是我到目前为止所拥有的。当我按下它时,是否有更改这些xml按钮上的图像?任何想法都会有所帮助,谢谢!

Edit: So I ran into this website http://www.javacodegeeks.com/2012/03/gwt-custom-button-using-uibinder.html and it shows how to add an image to a button. I would like to do the same thing but instead of having a static image I want the image to change every time I clicked done or cancel.

编辑:所以我跑进了这个网站http://www.javacodegeeks.com/2012/03/gwt-custom-button-using-uibinder.html,它显示了如何将图像添加到按钮。我想做同样的事情,但我没有静态图像,而是希望每次点击完成或取消时图像都会改变。

Edit: current I have a label and image. I want to be able to change that image every time I press a button.

编辑:当前我有一个标签和图像。我希望每次按下按钮都能更改该图像。

private static buttonclickersUiBinder uiBinder = GWT
        .create(buttonclickersUiBinder.class);
@UiField PushButton button_1;
@UiField PushButton button_2;
@UiField Image checkimage;
@UiField Label label_one;

interface buttonclickersUiBinder extends UiBinder<Widget, buttonclickers> {
}

public buttonclickers() {
    initWidget(uiBinder.createAndBindUi(this));
}

@UiHandler("button_1")
void onButton_1Click(ClickEvent event) {
    AppUtils.EVENT_BUS.fireEvent(new ButtonEvent());
}
@UiHandler("button_2")
void onButton_2Click(ClickEvent event) {
}
@UiHandler("checkimage")
void onCheckimageClick(ClickEvent event) {
    Window.alert("hit");
    AppUtils.EVENT_BUS.fireEvent(new ButtonEvent());

}
@UiHandler("label_one")
void onLabel_oneClick(ClickEvent event) {
    AppUtils.EVENT_BUS.fireEvent(new ButtonEvent());

}
}

I understand we have checkimage as the id. is it possible that I just add other images into the xml and call it whenever something is pressed?

我知道我们有checkimage作为id。是否有可能我只是将其他图像添加到xml中并在按下某个内容时调用它?

1 个解决方案

#1


0  

actually I figured it out. you add " checkimage.setUrl("mvpwebapp/gwt/clean/images/xmark.png"); " to change the images.

实际上我想通了。你添加“checkimage.setUrl(”mvpwebapp / gwt / clean / images / xmark.png“);”更改图像。


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
  © 2014-2022 ITdaan.com 联系我们: