我有一个水平分割面板,我想在其中显示组合框中选择的图像,但无法设置图像文件的数据源。
FilesystemContainer container = new FilesystemContainer(new File("C:/myData/wallpaper"));
ComboBox box = new ComboBox("Documents", container);
@Override
protected void init(VaadinRequest request) {
setContent(box);
com.vaadin.ui.HorizontalSplitPanel horizontalSplitPanel = new com.vaadin.ui.HorizontalSplitPanel();
setContent(horizontalSplitPanel);
horizontalSplitPanel.addComponent(box);
//horizontalSplitPanel.addComponent(label);
final Image image = new Image();
horizontalSplitPanel.addComponent(image);
box.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
image.setData(event.getProperty().getValue());
///label.set//setPropertyDataSource( (Property) ImageIO.read((ImageInputStream) new TextFileProperty((File) event.getProperty().getValue())));
}
});
box.setImmediate(true);
如何设置图像的数据源。我是 Vaadin 的新手。
最佳答案
我建议这样:
@Override
public void valueChange(ValueChangeEvent event) {
image.setSource(new FileResource((File)box.getValue()));
}
关于java - 如何在vaadin中设置图像数据源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27182816/