1
나는 netbeans에서 javafx fxml 프로젝트를 사용하여 응용 프로그램을 작성하고 있습니다. 컨트롤러의 일부로 노드를 인쇄 중입니다. 이를 위해 노드 레이아웃을 변경하여 절반 페이지에 맞출 수 있습니다. 이제 인쇄가 끝나면 어떻게 원래 레이아웃으로 되돌아갑니다. 더 구체적으로, 모든 설정을 초기화하는 방법이 있습니까? 자바 FX와 자바에서 내 전문 지식은 너무 :(붙여 넣기/잘라 코드 예제가 제공됩니다. 링크 Best way to initialize GUI in JavaFX? 답을 포함하는 것 감사하는 제한하지만 난 그것을 이해할 수 없습니다입니다.javafx 컨트롤러에서 초기화
public void print(final Node node) {
Printer printer = Printer.getDefaultPrinter();
PageLayout pageLayout = printer.createPageLayout(Paper.NA_LETTER, PageOrientation.PORTRAIT, Printer.MarginType.DEFAULT);
double width = node.getBoundsInParent().getWidth();
double height = node.getBoundsInParent().getHeight();
double scaleX = pageLayout.getPrintableWidth()/node.getBoundsInParent().getWidth();
double scaleY = pageLayout.getPrintableHeight() /(2* node.getBoundsInParent().getHeight());
node.getTransforms().add(new Scale(scaleX, scaleY));
PrinterJob job = PrinterJob.createPrinterJob();
if (job != null) {
boolean success = job.printPage(node);
if (success) {
job.endJob();
}
}
node.getTransforms().add(new Scale(width, height)); //This is not working
}
와
교체는 아름답게 :) 노력하고 있습니다, 감사합니다. 한 가지 더 묻습니다. 컨트롤러에서 응용 프로그램을 다시 실행하는 것처럼 전체 양식을 초기화하는 간단한 방법이 있습니까? \t \t public void start (Stage stage) throws Exception { 상위 루트 = FXMLLoader.load (getClass(). getResource ("FXMLDocument.fxml")); 장면 장면 = 새로운 장면 (루트); stage.setTitle ("Billbook"); stage.setScene (scene); stage.show(); } – jay