I am working on the filetransfer module in my javafx application. So it works great, but when I wanted to show progress, it freezes until it finishes downloading. So I decided to use threads to train progress, but the console keeps telling me that I'm not on javafx thread, even if I use
Platform.runLater(new Runnable() { @Override public void run() {
Here is my method that generates a popup that should show progress:
public void generateFilePopUpMessage(final Stage primaryStage, final FileTransferRequest request) { try { popup.show(primaryStage); aceptar.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { class MyRunnable2 implements Runnable { public Label mensaje; public Label getMensaje() { return mensaje; } public void setMensaje(Label mensaje) { this.mensaje = mensaje; } @Override public void run() {
And here is the code where I call the popup:
manager.addFileTransferListener(new FileTransferListener() { public void fileTransferRequest(final FileTransferRequest request) { // broadcast something here. Wheather users want to accept file // Check to see if the request should be accepted boolean accept = false; Platform.runLater(new Runnable() { @Override public void run() { popupFile.generateFilePopUpMessage(stage, request); popupFile.getUsuario().setText(request.getRequestor()); long size = bytesToMeg(request.getFileSize()); String tam = ""; if (size <= 0) { size = bytesToK(request.getFileSize()); tam = "" + size + "Kb"; } else { tam = "" + size + "Mb"; } popupFile.getMensaje().setText( "Le envía el siguiente archivo: " + request.getFileName() + ", que pesa: " + tam); } }); } });
How can i fix this ?? Thanks at advace.
source share