Bonjour,

La classe ci-dessous extends de JFXPanel.

Je dois y mettre un fxml qui prend une dizaine de secondes à se charger (tableView avec +/- 10000 lignes).

Lorsque je lance l'application, je ne vois d'abord rien pendant quelques secondes, ensuite je vois une partie de ma scène en haut à gauche de l'écran et enfin, lorsque tout est chargé, l'écran s'affiche complétement.

J'ai donc essayé de faire une scène d'attente qui afficherait un simple fxml (appelé" SplashLoad.fxml")

Le but est normalement d'afficher SplashLoad.fxml et puis de lancer le FxmlLoader de ma grosse scène dans un runlater... et quand ce dernier est chargé, de remplacer le splash par ma scene principale.

mais rien n'y fait, mon splash ne s'affiche qu'une ou deux secondes dans le coin supérieur gauche, il est vite remplacé par mon gros FXML (toujours dans le coin supérieur gauche) jusqu'à la fin du chargement ou là mon écran s'affiche normalement.



Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
 
public class GeneriqueFxPanel2 extends JFXPanel
{
	private String				fxmlPath;
	private GeneriqueFxPanel2	myGP;
 
	private Parent				root;
	private Scene				scene;
 
	public GeneriqueFxPanel2(String fxmlPath)
	{
 
		myGP = this;
		this.fxmlPath = fxmlPath;
 
		SwingUtilities.invokeLater(new Runnable()
		{
			@Override
			public void run()
			{
				initAndShowGUI();
			}
		});
 
	}
 
	private void initAndShowGUI()
	{
 
		Platform.runLater(new Runnable()
		{
			@Override
			public void run()
			{
 
				initFX();
			}
		});
	}
 
	private void initFX()
	{
		// This method is invoked on the JavaFX thread
		try
		{
 
			ApplicationController.getInstance().setWaitState(ApplicationController.getInstance().getMother(), true);
			final FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource("be/aaa/bbb/" + fxmlPath));
 
			Parent rootSplash;
			Scene sceneSplash;
 
			FXMLLoader fxmlLoaderSplash = new FXMLLoader(getClass().getClassLoader().getResource("be/aaa/bbb/newmod/gui/SplashLoad.fxml"));
 
			rootSplash = (Parent) fxmlLoaderSplash.load();
			sceneSplash = new Scene(rootSplash, 250, 250);
 
			this.setScene(sceneSplash);
 
 
			Platform.runLater(new Runnable()
			{
				@Override
				public void run()
				{
 
					try
					{
 
						root = (Parent) fxmlLoader.load();
						scene = new Scene(root, 250, 250);
 
						myGP.setScene(scene);
					}
					catch (Exception e)
					{
						// TODO: handle exception
					}
 
				}
			});
 
			ApplicationController.getInstance().setWaitState(ApplicationController.getInstance().getMother(), false);
 
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
 
}