JavaCAD
JavaFXInitializer.java
Go to the documentation of this file.
1 package eu.mihosoft.vrl.v3d;
2 
3 public class JavaFXInitializer {
4  private static final int NUM_COUNT = 2;
5  private final static java.util.concurrent.CountDownLatch latch = new java.util.concurrent.CountDownLatch(NUM_COUNT);
6  public static boolean errored=false;
7  public JavaFXInitializer(){
8 
9  }
10  private static void gointernal() {
11  if(latch.getCount()!=NUM_COUNT) {
12  //System.out.println("ERR initializer already started");
13  return;
14  }
15  System.out.println("Starting JavaFX initializer..."+JavaFXInitializer.class);
16  latch.countDown();
17  try {
18  final javafx.embed.swing.JFXPanel fxPanel = new javafx.embed.swing.JFXPanel();
19  latch.countDown();
20  }catch(Throwable e) {
21  latch.countDown();
22  errored=true;
23  e.printStackTrace();
24  }
25  }
26  public static void go() {
27  if(latch.getCount()!=NUM_COUNT) {
28  //System.out.println("ERR initializer already started");
29  return;
30  }
31  new Thread() {
32  public void run() {
33  try {
34  gointernal();
35  }catch(Throwable t) {
36  t.printStackTrace();
37  errored=true;
38  }
39  }
40  }.start();
41  try {
42  JavaFXInitializer.latch.await();
43  } catch (Throwable e) {
44  e.printStackTrace();
45  errored=true;
46  }
47  StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace();
48  StackTraceElement e = stacktrace[2];//maybe this number needs to be corrected
49  System.out.println("Finished JavaFX initializing! "+e);
50  }
51 
52 }
static final java.util.concurrent.CountDownLatch latch