From: Ivan Pribela Date: Fri, 8 Dec 2017 20:16:08 +0000 (+0100) Subject: Lavirint, objedinjeno resenje, doterana inicijalizacija sistema za prikaz X-Git-Url: https://svarog.pmf.uns.ac.rs/gitweb/?a=commitdiff_plain;h=55ed350e20173295a9a7bbf40aaf55e59d065dd9;p=spa2-materijali.git Lavirint, objedinjeno resenje, doterana inicijalizacija sistema za prikaz --- diff --git a/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Prikaz.java b/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Prikaz.java index 4553a24..92e2755 100644 --- a/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Prikaz.java +++ b/PretrazivanjeSaVracanjem/Lavirint/SuperKomplikovanoResenje/Prikaz.java @@ -3,6 +3,7 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.CountDownLatch; import java.util.function.Function; import javafx.application.Application; @@ -11,7 +12,6 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.geometry.Insets; import javafx.geometry.VPos; -import javafx.embed.swing.JFXPanel; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; @@ -334,6 +334,8 @@ public class Prikaz extends Application { primaryStage.setScene(scene); primaryStage.show(); + pokrenut.countDown(); + } protected static void osveziPanelZaAnimaciju(Label labela, Button dugme, double vrednost) { @@ -475,12 +477,26 @@ public class Prikaz extends Application { // Pokretanje // //////////////// + protected static CountDownLatch pokrenut = new CountDownLatch(1); + protected static void pokreni() { - new JFXPanel(); Runnable launcher = () -> { launch(new String[] {}); }; new Thread(launcher).start(); + boolean bioPrekid = Thread.interrupted(); + boolean ok = false; + do { + try { + pokrenut.await(); + ok = true; + } catch (InterruptedException e) { + bioPrekid = true; + } + } while (!ok); + if (bioPrekid) { + Thread.currentThread().interrupt(); + } } protected static void odradiKasnije(Runnable zadatak) {