我想在JavaFx中实现进度条,它将指示使用xdocreport(docx或pdf文件)创建报告的状态。任何sugestions我怎么能实现这一点。一些例子?我怎样才能使用Thread?
我试过这样但有些东西不起作用。
/**
* Called when the user clicks the assign button. Generates Report about Employee
*
*/
@FXML
private void generateEmployeeReport() {
Task<Void> task = new Task<Void>() {
@Override public Void call() {
try {
// 1) Load Docx file by filling Velocity template engine and cache
// it to the registry
InputStream in = RootController.class
.getResourceAsStream("ReportEmployeeTemplate.docx");
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(
in, TemplateEngineKind.Velocity);
// 2) Create context Java model
IContext context = report.createContext();
ReportEmployee project = new ReportEmployee("Majmun");
context.put("ReportEmployee", project);
// 3) Generate report by merging Java model with the Docx
OutputStream out = new FileOutputStream(new File(
"bzzer.pdf"));
// report.process(context, out);
Options options = Options.getTo(ConverterTypeTo.PDF).via(
ConverterTypeVia.XWPF);
report.convert(context, options, out);
} catch (IOException e) {
e.printStackTrace();
} catch (XDocReportException e) {
e.printStackTrace();
}
return null;
}
};
progresBarOne.progressProperty().bind(task.progressProperty());
Thread th = new Thread(task);
th.setDaemon(true);
th.start();
}
创建了文件,但进度条一直显示一些工作(保持&#34;表示&#34;进度)