如何在GWT中的另一个类中使用UiField

时间:2013-07-18 23:54:35

标签: java oop gwt user-interface widget

目前我有一个标签和图片。当按下标签或图像时,它将调出面板1。面板一旦启动,有三个按钮选项。如果按下完成,将出现一个复选标记。如果按取消,则会出现一个X,当按下时,将出现一个时钟。

这是图片和标签所在的标签页

public class buttonclickers extends Composite {

boolean buttonone = false;
boolean buttontwo = false;

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) {
    buttonone = true;
    buttontwo = false;
    AppUtils.EVENT_BUS.fireEvent(new ButtonEvent());


}
@UiHandler("button_2")
void onButton_2Click(ClickEvent event) {
    buttontwo = true;
    buttonone = false;
    AppUtils.EVENT_BUS.fireEvent(new ButtonEvent());


}
@UiHandler("checkimage")
void onCheckimageClick(ClickEvent event) {
    //Window.alert("hit");
    AppUtils.EVENT_BUS.fireEvent(new ButtonEvent());
    checkimage.setUrl("mvpwebapp/gwt/clean/images/xmark.png");

}

@UiHandler("label_one")
void onLabel_oneClick(ClickEvent event) {
    AppUtils.EVENT_BUS.fireEvent(new ButtonEvent());
    checkimage.setUrl("mvpwebapp/gwt/clean/images/xmark.png");


}
public int checkbuttonclick()
{
    int butt_one = 1;
    int butt_two = 2;

    if(buttonone == true)
    {
        return butt_one;
    }
    else if(buttontwo == true)
    {
        return butt_two;
    }
    else
        return 0;
}



}

以下是我希望能够使用的课程

public class panelOne extends Composite {
boolean button_cancel = false;
boolean button_pending = false;
boolean button_done = false;
private static panelOneUiBinder uiBinder = GWT
        .create(panelOneUiBinder.class);
@UiField PushButton done;
@UiField PushButton cancel;
@UiField PushButton pending;

interface panelOneUiBinder extends UiBinder<Widget, panelOne> {
}

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

@UiHandler("cancel")
void onCancelClick(ClickEvent event) {
    button_cancel = true;
    button_pending = false;
    button_done = false;
    Window.alert("cancel");
    AppUtils.EVENT_BUS.fireEvent(new ButtonEvent());

}
@UiHandler("pending")
void onPendingClick(ClickEvent event) {
    button_cancel = false;
    button_pending = true;
    button_done = false;
    Window.alert("pending");
    AppUtils.EVENT_BUS.fireEvent(new ButtonEvent());

}
@UiHandler("done")
void onDoneClick(ClickEvent event) {
    button_cancel = false;
    button_pending = false;
    button_done = true;
    Window.alert("done");
    AppUtils.EVENT_BUS.fireEvent(new ButtonEvent());


}
}

我想提出

  

checkimage.setUrl( “mvpwebapp / GWT /清洁/图像/ xmark.png”);

进入我的panelOne类而不是在buttonclickers类中。我这样做是因为我想将图像从支票更改为X.我在网上查找了一些内容,但我对如何应用它感到很困惑。

谢谢

0 个答案:

没有答案