我在Java中使用Vaadin,我正在学习本教程:Vaadin Upload 所以我创建了一个新的Class名称上传器。但是有一些东西不中我的代码工作,我把什么是不工作的** **的文字:Vaadin上传“无法解析符号”错误上传教程
import com.vaadin.server.FileResource;
import com.vaadin.ui.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
/**
* Created by mflamant on 15/05/2017.
*/
public class Uploader {
final Embedded image = new Embedded("Uploaded image");
**image.setVisible(false);**
class Image implements Upload.Receiver, Upload.SucceededListener{
public File file;
public OutputStream receiveUpload(String filename, String mimeType){
FileOutputStream fos = null;
try{
file = new File(filename);
fos = new FileOutputStream(file);
} catch (final java.io.FileNotFoundException e){
e.printStackTrace();
return null;
}
return fos;
}
public void uploadSucceeded(Upload.SucceededEvent event){
image.setVisible(true);
image.setSource(new FileResource(file));
}
};
Image receiver = new Image();
Upload upload = new Upload("Upload image here", receiver);
**upload.setButtonCaption("Start Upload");**
**upload.SucceededListener(receiver);**
Panel panel = new Panel("Image storage");
Layout panelContent = new VerticalLayout();
**panelContent.addComponents(upload, image);**
**panel.setContent;**
}
我的错误是“无法解析符号”。你能向我解释为什么这些线路不工作?
'不工作'是对您的问题的一个非常模糊的描述。你需要清楚地解释[什么不起作用](https://stackoverflow.com/help/how-to-ask)。是否有编译错误,运行时错误,意外行为? –
对不起,我的IDE中只有红色。用“无法解析符号” –