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........
I want to execute the above class from Class B
我想从B类执行上面的类
Method is class B - below
方法是B类-下面。
public void startPDFPrint() throws Exception {
AplotPdfPrintLocal pdfPrint = new AplotPdfPrintLocal(getPDFFileName()).run();
}
I am getting a error that I need to change the return type of run from void to plotPdfPrintLocal
我得到一个错误,我需要将run的返回类型从void更改为plotPdfPrintLocal
Am I going about calling the class wrong?
我是不是要把这堂课叫错了?
1 个解决方案
#1
4
Change it to:
把它改成:
public void startPDFPrint() throws Exception {
AplotPdfPrintLocal pdfPrint = new AplotPdfPrintLocal(getPDFFileName());
pdfPrint.run();
}
or
或
public void startPDFPrint() throws Exception {
new AplotPdfPrintLocal(getPDFFileName()).run();
}
what the compiler is saying is that you're trying to assign the result of the run method (void) to left member of the expression, the AplotPdfPrintLocal pdfPrint variable.
编译器说的是,您试图将run方法(void)的结果分配给表达式的左成员aplotpdfprintpdfprintpdfprint变量。
So, due to the fact that run is "returning" void, there is an error, a discrepancy between the expected AplotPdfPrintLocal type (declared on the left side) and the actual return type: void.
因此,由于run是“return”void,所以在预期的AplotPdfPrintLocal类型(在左边声明)和实际的return类型之间存在一个错误,即void。
#1
4
Change it to:
把它改成:
public void startPDFPrint() throws Exception {
AplotPdfPrintLocal pdfPrint = new AplotPdfPrintLocal(getPDFFileName());
pdfPrint.run();
}
or
或
public void startPDFPrint() throws Exception {
new AplotPdfPrintLocal(getPDFFileName()).run();
}
what the compiler is saying is that you're trying to assign the result of the run method (void) to left member of the expression, the AplotPdfPrintLocal pdfPrint variable.
编译器说的是,您试图将run方法(void)的结果分配给表达式的左成员aplotpdfprintpdfprintpdfprint变量。
So, due to the fact that run is "returning" void, there is an error, a discrepancy between the expected AplotPdfPrintLocal type (declared on the left side) and the actual return type: void.
因此,由于run是“return”void,所以在预期的AplotPdfPrintLocal类型(在左边声明)和实际的return类型之间存在一个错误,即void。