What's the problem?



  • In class. ControllerMainManu:

    if (ChoiceRe.getText() == "Обычный") {
        System.out.println("Обычный режим запущен");
        TimeStart = Integer.toString(normalTime);
        try {
            x = new Formatter("src//application//res//Re//TemporaryTimeStart.txt");
            x.format(TimeStart);
        } catch (FileNotFoundException e) {}
        x.close();
        WindowNormalReTimer windowNormalReTimer = new WindowNormalReTimer(HelperTime);
        Thread t1 = new Thread(windowNormalReTimer);
        time.progressProperty().bind(progress);
        t1.start();
        Indicator i = new Indicator();
        i.j(null);
    }
    

    In class. Indicator:

    public class Indicator extends Application {
    

    @Override
    public void start(Stage primaryStage) throws IOException {
    ProgressIndicator progressIndicator = new ProgressIndicator(0);

      Task<Void> task = new Task<Void>() {
    
        @Override
        protected Void call() throws Exception {
            double TimeStart = 0d;
            for (int row = 0; row < 100; row++) {
                TimeStart = TimeStart + 0.01;
                updateProgress(TimeStart, 1);
                try {
                    Thread.sleep(27);
                } catch (InterruptedException e) {
                }
            }
            return null;
        }
      };
      progressIndicator.progressProperty().bind(task.progressProperty());
    
      Executors.newCachedThreadPool().submit(task);
    
      Scene scene = new Scene(progressIndicator);
      primaryStage.setScene(scene);
      primaryStage.show();
    

    }

    public static void j(String[] args) {
    launch(args);
    }

    }

    There's a mistake:

    java.lang.reflect.InvocationTargetException at
    javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source) at
    javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source) at
    com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source) at
    com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source) at
    com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source) at
    com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source) at
    com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at
    com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at
    com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at
    com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at
    com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at
    com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at
    com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source) at
    com.sun.javafx.event.EventUtil.fireEvent(Unknown Source) at
    javafx.event.Event.fireEvent(Unknown Source) at
    javafx.scene.Node.fireEvent(Unknown Source) at
    javafx.scene.control.Button.fire(Unknown Source) at
    com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Unknown Source) at
    com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source) at
    com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source) at
    com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source) at
    com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source) at
    com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source) at
    com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source) at
    com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source) at
    com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at
    com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at
    com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at
    com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at
    com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at
    com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at
    com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source) at
    com.sun.javafx.event.EventUtil.fireEvent(Unknown Source) at
    javafx.event.Event.fireEvent(Unknown Source) at
    javafx.scene.Scene$MouseHandler.process(Unknown Source) at
    javafx.scene.Scene$MouseHandler.access$1500(Unknown Source) at
    javafx.scene.Scene.impl_processMouseEvent(Unknown Source) at
    javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source) at
    com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source) at
    com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source) at
    java.security.AccessController.doPrivileged(Native Method) at
    com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source) at
    com.sun.glass.ui.View.handleMouseEvent(Unknown Source) at
    com.sun.glass.ui.View.notifyMouse(Unknown Source) at
    com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at
    com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source) at
    com.sun.glass.ui.win.WinApplication$$Lambda$37/2075313.run(Unknown Source) at
    java.lang.Thread.run(Unknown Source) Caused by: java.lang.reflect.InvocationTargetException at
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
    java.lang.reflect.Method.invoke(Unknown Source) at
    sun.reflect.misc.Trampoline.invoke(Unknown Source) at
    sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
    java.lang.reflect.Method.invoke(Unknown Source) at
    sun.reflect.misc.MethodUtil.invoke(Unknown Source)
    ... 48 more Caused by: java.lang.IllegalStateException: Application launch must not be called more than once at
    com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source) at
    com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source) at
    javafx.application.Application.launch(Unknown Source) at
    application.Indicator.j(Indicator.java:44) at
    application.ControllerMainMenu.start(ControllerMainMenu.java:280) ... 57 more



  • According to the http://docs.oracle.com/javase/8/javafx/api/javafx/application/Application.html#launch-java.lang.Class-java.lang.String...- to method launch():

    Launch a standalone application. This method is typically called from the main method(). It must not be called more than once or an exception will be thrown.

    As you can see, this method cannot be called more than once, otherwise there will be an exception that occurs in your case.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2