public class Main extends Application {
private Stage stage;
private Scene scene;
private AnchorPane loading;
public Timer timer;
public int timerV, stageV;
Menu m = new Menu();
public void start(Stage stage) throws Exception{
loading = (AnchorPane) FXMLLoader.load(Main.class.getResource("res/1 loading/paw.fxml"));
scene = new Scene(loading);
this.stage = stage;
stage.setY(225);
stage.setX(430);
stage.initStyle(StageStyle.UNDECORATED);
stage.setScene(scene);
stage.show();
timer = new Timer(1000, null);
timer.start();
timer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
timerV++;
if(timerV==15){
m.stage.show();
timer.stop();
}
}
});
}
public static void main(String[] args) {
launch(args);
}
}
Надеюсь, смысл понятен. Тут просто запускается одна сцена после другой, но как в том-то и проблема, что она не запускается... Почему-то все параметры из JFX(a) не работают внутри таймера из Swing(a). Вот, что пишет консоль:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Main$1.actionPerformed(Main.java:35)
at java.desktop/javax.swing.Timer.fireActionPerformed(Timer.java:317)
at java.desktop/javax.swing.Timer$DoPostEvent.run(Timer.java:249)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)