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 联系我们: