2012-11-12 35 views
0
public class AplotPdfPrintLocal extends ApplicationWindow { 
private String userSelectedFile; 

public AplotPdfPrintLocal(String pdfFilePath) { 
    super(null); 
    this.userSelectedFile = pdfFilePath; 
} 

public void run() { 
    setBlockOnOpen(true); 
    open(); 
    Display.getCurrent().dispose(); 
} 

etc........ 

我想從B類執行上面的類我如何從B級執行A類的run方法

的方法是B級 - 低於

public void startPDFPrint() throws Exception { 
     AplotPdfPrintLocal pdfPrint = new AplotPdfPrintLocal(getPDFFileName()).run(); 
} 

我得到一個錯誤我需要將運行的返回類型從void改爲plotPdfPrintLocal

我是否在調用類錯誤?

回答

4

將其更改爲:

public void startPDFPrint() throws Exception { 
     AplotPdfPrintLocal pdfPrint = new AplotPdfPrintLocal(getPDFFileName()); 
     pdfPrint.run(); 
} 

public void startPDFPrint() throws Exception { 
     new AplotPdfPrintLocal(getPDFFileName()).run(); 
} 

什麼編譯器的意思是,你要分配的run方法(無效)向左成員的結果的表達方式,AplotPdfPrintLocal pdfPrint變量。

因此,由於這樣的事實:運行是「迴歸」 無效,有錯誤,預期AplotPdfPrintLocal型(左側聲明)之間的差異和實際的返回類型:void

相關問題