いろいろ調べてみて結果、
というのを使えばいいようです。
サンプルコードは下記のリンクより。
ポイントだけ書くと
class OurChangeEvent extends ChangeEvent {}
と書いて
textBox.fireEvent(new OurChangeEvent());
と書くと、OnChangeイベントが呼び出せるという感じです。
final TextBox tb = new TextBox(); tb.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (event.getCharCode()==' '){ MyPopPuPanel pop = new MyPopPuPanel(); pop.setPopupPosition(tb.getOffsetWidth(), tb.getAbsoluteTop()); pop.setAutoHideEnabled(true); pop.show(); event.preventDefault(); } }
package com.example.myufirstvaadin;
import java.io.File;
import com.vaadin.Application;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.terminal.FileResource;
import com.vaadin.terminal.gwt.server.WebApplicationContext;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
public class MyufirstvaadinApplication extends Application {
@Override
public void init() {
Window mainWindow = new Window("Myufirstvaadin Application");
Label label = new Label("Hello Vaadin user");
mainWindow.addComponent(label);
Button dounloadButton = new Button("ダウンロード");
mainWindow.addComponent(dounloadButton);
dounloadButton.addListener(new ClickListener() {
/**
*
*/
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
event.getButton().getWindow().open(new FileResource(new File("C:\\Users\\2006.pdf"),MyufirstvaadinApplication.this));
}
});
setMainWindow(mainWindow);
}
}