我在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中只有紅色。用「無法解析符號」 –