Olá, companheiros. Sou um novo estudante de Java com foco em JavaFX. Recentemente estou aprendendo, dentre muitas coisas, a mexer com navegações de tela, fiz alguns testes e todos funcionaram. Agora fui fazer um teste sozinho e está dando erro e não consigo identificar exatamente o que está acontecendo. Irei deixar o programa aqui, se alguém puder me ajudar ficarei muito agradecido.
// Ignorem o “Friboi”, tem a ver com o teste que estou fazendo. É imaginário, kkkk.
// Ignorem as partes incompletas, eu comecei esse programa agora.
Classe Principal:
package tela;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class EncontroFriboi extends Application {
private static Stage stagePrincipal;
private static Scene scenePrincipal;
private static Scene sceneConvidados;
@Override
public void start(Stage stage) throws Exception{
stagePrincipal = stage;
stage.setTitle("Painel de Controle - Encontro Friboi");
stage.setMaximized(true);
Parent principal = FXMLLoader.load(getClass().getResource("FXMLEncontroFriboi.fxml"));
scenePrincipal = new Scene(principal);
Parent convidados = FXMLLoader.load(getClass().getResource("FXMLConvidados.fxml"));
sceneConvidados = new Scene(convidados);
stage.setScene(scenePrincipal);
stage.show();
}
public static void mudarTela(String click){
switch(click){
case "convidados":
stagePrincipal.setScene(sceneConvidados);
}
}
public static void main(String[] args) {
launch(args);
}
}
FXMLEncontroFriboiController:
package tela;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
public class FXMLEncontroFriboiController implements Initializable {
@FXML
private Button btnConvidados;
@FXML
private Button btnItens;
@FXML
private Button btnEstimativa;
@FXML
private Button btnConvite;
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
@FXML
private void clicarConvidados(ActionEvent event) {
EncontroFriboi.mudarTela("convidados");
}
@FXML
private void clicarItens(ActionEvent event) {
}
@FXML
private void clicarEstimativa(ActionEvent event) {
}
@FXML
private void clicarConvite(ActionEvent event) {
}
}
O ERRO:
[echo] Executing C:\Users\conta\OneDrive\Documentos\NetBeansProjects\EncontroFriboi\dist\run1660773924\EncontroFriboi.jar using platform C:\Program Files\Java\jdk1.8.0_291/bin/java
[java] Exception in Application start method
[java] java.lang.reflect.InvocationTargetException
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:498)
[java] at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
[java] at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:498)
[java] at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:873)
[java] Caused by: java.lang.RuntimeException: Exception in Application start method
[java] at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
[java] at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182)
[java] at java.lang.Thread.run(Thread.java:748)
[java] Caused by: javafx.fxml.LoadException:
[java] file:/C:/Users/conta/OneDrive/Documentos/NetBeansProjects/EncontroFriboi/dist/run1660773924/EncontroFriboi.jar!/tela/FXMLEncontroFriboi.fxml:8
[java]
[java] at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
[java] at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:103)
[java] at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:922)
[java] at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)
[java] at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
[java] at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
[java] at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
[java] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
[java] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
[java] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
[java] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
[java] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
[java] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
[java] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
[java] at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
[java] at tela.EncontroFriboi.start(EncontroFriboi.java:30)
[java] at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
[java] at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
[java] at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
[java] at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
[java] at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
[java] at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:185)
[java] ... 1 more
[java] Caused by: java.lang.ClassNotFoundException: encontrofriboi.FXMLEncontroFriboiController
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
[java] at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:920)
[java] ... 22 more
[java] Exception running application tela.EncontroFriboi
[java] Java Result: 1
-remove-temp-run-dir:
[delete] Deleting directory C:\Users\conta\OneDrive\Documentos\NetBeansProjects\EncontroFriboi\dist\run1660773924