Lucas_Camara 14 de ago. de 2020
Tenta assim:
getClass (). getResource ( "../layout/LoginFXML.fxml" )
Arthur3 14 de ago. de 2020
Continua dando erro…
Exception in Application start method
java . lang . reflect . InvocationTargetException
at sun . reflect . NativeMethodAccessorImpl . invoke0 ( Native Method )
at sun . reflect . NativeMethodAccessorImpl . invoke ( NativeMethodAccessorImpl . java : 62 )
at sun . reflect . DelegatingMethodAccessorImpl . invoke ( DelegatingMethodAccessorImpl . java : 43 )
at java . lang . reflect . Method . invoke ( Method . java : 498 )
at com . sun . javafx . application . LauncherImpl . launchApplicationWithArgs ( LauncherImpl . java : 389 )
at com . sun . javafx . application . LauncherImpl . launchApplication ( LauncherImpl . java : 328 )
at sun . reflect . NativeMethodAccessorImpl . invoke0 ( Native Method )
at sun . reflect . NativeMethodAccessorImpl . invoke ( NativeMethodAccessorImpl . java : 62 )
at sun . reflect . DelegatingMethodAccessorImpl . invoke ( DelegatingMethodAccessorImpl . java : 43 )
at java . lang . reflect . Method . invoke ( Method . java : 498 )
at sun . launcher . LauncherHelper$FXHelper . main ( LauncherHelper . java : 873 )
Caused by : java . lang . RuntimeException : Exception in Application start method
at com . sun . javafx . application . LauncherImpl . launchApplication1 ( LauncherImpl . java : 917 )
at com . sun . javafx . application . LauncherImpl . lambda$launchApplication$1 ( LauncherImpl . java : 182 )
at java . lang . Thread . run ( Thread . java : 748 )
Caused by : javafx . fxml . LoadException :
/ C : / Users / Talita / Documents / NetBeansProjects / app - tarefas / build / classes / br / com / mask / tarefas / login / layout / LoginFXML . fxml : 9
at javafx . fxml . FXMLLoader . constructLoadException ( FXMLLoader . java : 2601 )
at javafx . fxml . FXMLLoader . access $ 700 ( FXMLLoader . java : 103 )
at javafx . fxml . FXMLLoader $ ValueElement . processAttribute ( FXMLLoader . java : 922 )
at javafx . fxml . FXMLLoader $ InstanceDeclarationElement . processAttribute ( FXMLLoader . java : 971 )
at javafx . fxml . FXMLLoader $ Element . processStartElement ( FXMLLoader . java : 220 )
at javafx . fxml . FXMLLoader $ ValueElement . processStartElement ( FXMLLoader . java : 744 )
at javafx . fxml . FXMLLoader . processStartElement ( FXMLLoader . java : 2707 )
at javafx . fxml . FXMLLoader . loadImpl ( FXMLLoader . java : 2527 )
at javafx . fxml . FXMLLoader . loadImpl ( FXMLLoader . java : 2441 )
at javafx . fxml . FXMLLoader . loadImpl ( FXMLLoader . java : 3214 )
at javafx . fxml . FXMLLoader . loadImpl ( FXMLLoader . java : 3175 )
at javafx . fxml . FXMLLoader . loadImpl ( FXMLLoader . java : 3148 )
at javafx . fxml . FXMLLoader . loadImpl ( FXMLLoader . java : 3124 )
at javafx . fxml . FXMLLoader . loadImpl ( FXMLLoader . java : 3104 )
at javafx . fxml . FXMLLoader . load ( FXMLLoader . java : 3097 )
at br . com . mask . tarefas . login . layout . LoginSystem . start ( LoginSystem . java : 16 )
at com . sun . javafx . application . LauncherImpl . lambda $ launchApplication1 $ 8 ( LauncherImpl . java : 863 )
at com . sun . javafx . application . PlatformImpl . lambda $ runAndWait $ 7 ( PlatformImpl . java : 326 )
at com . sun . javafx . application . PlatformImpl . lambda $ null $ 5 ( PlatformImpl . java : 295 )
at java . security . AccessController . doPrivileged ( Native Method )
at com . sun . javafx . application . PlatformImpl . lambda $ runLater $ 6 ( PlatformImpl . java : 294 )
at com . sun . glass . ui . InvokeLaterDispatcher $ Future . run ( InvokeLaterDispatcher . java : 95 )
at com . sun . glass . ui . win . WinApplication . _runLoop ( Native Method )
at com . sun . glass . ui . win . WinApplication . lambda $ null $ 4 ( WinApplication . java : 186 )
… 1 more
Caused by : java . lang . ClassNotFoundException : LoginFXMLController
at java . net . URLClassLoader . findClass ( URLClassLoader . java : 382 )
at java . lang . ClassLoader . loadClass ( ClassLoader . java : 418 )
at sun . misc . Launcher $ AppClassLoader . loadClass ( Launcher . java : 355 )
at java . lang . ClassLoader . loadClass ( ClassLoader . java : 351 )
at javafx . fxml . FXMLLoader $ ValueElement . processAttribute ( FXMLLoader . java : 920 )
… 22 more
Exception running application br . com . mask . tarefas . login . layout . LoginSystem
C : \Users \Talita \Documents \NetBeansProjects \app - tarefas \nbproject \build - impl . xml : 1052 : The following error occurred while executing this line :
C : \Users \Talita \Documents \NetBeansProjects \app - tarefas \nbproject \build - impl . xml : 806 : Java returned : 1
FALHA NA CONSTRUÇÃO ( tempo total : 2 segundos )
Lucas_Camara 14 de ago. de 2020
Onde que está essa classe LoginFXMLController ?
Arthur3 14 de ago. de 2020
Lucas_Camara 14 de ago. de 2020
E como essa classe está sendo referenciada no arquivo LoginFXML.fxml na linha 9 (LoginFXML.fxml:9)?
Arthur3 14 de ago. de 2020
linha 9 do arquivo FXML
AnchorPane id=“AnchorPane” prefHeight=“200” prefWidth=“320” xmlns:fx=“http://javafx.com/fxml/1 ” fx:controller=“LoginFXMLController”>
Lucas_Camara 14 de ago. de 2020
Tente colocar o endereço completo da classe: br.com.mask.tarefas.login.layout.LoginFXMLController
Pergunta: A classe LoginSystem também está dentro do pacote layout ? Na sua pergunta, ela parece que está dentro do pacote login .
Arthur3 14 de ago. de 2020
Não,esta dentro do pacote Login… colocar o endereço você se refere ao codigo? pois o codigo esta padrão ainda, nem cheguei a mexer, e ele esta junto com o arquivo FXML.
Arthur3 14 de ago. de 2020
O codigo da classe Controller
import java.net.URL ;
import java.util.ResourceBundle ;
import javafx.event.ActionEvent ;
import javafx.fxml.FXML ;
import javafx.fxml.Initializable ;
import javafx.scene.control.Label ;
public class LoginFXMLController implements Initializable {
@FXML
private Label label ;
@FXML
private void handleButtonAction ( ActionEvent event ) {
System . out . println ( "You clicked me!" );
label . setText ( "Hello World!" );
}
@Override
public void initialize ( URL url , ResourceBundle rb ) {
}
}
Lucas_Camara 14 de ago. de 2020 1 like
Tente alterar o fxml para ficar assim:
fx : controller = “ br . com . mask . tarefas . login . layout . LoginFXMLController ”
Arthur3 14 de ago. de 2020
Desculpa, mas coloca aonde?
Solucao aceita
Lucas_Camara 14 de ago. de 2020 1 like
Dentro do arquivo fxml, onde fica esse fx:controller .
Arthur3 14 de ago. de 2020 1 like
Arthur3 14 de ago. de 2020
na verdade deu certo um problema, agora tem a questão de mapear o root para a classe LoginSystem, pois quando a classe que inicializa(LoginSystem), da erro pois não encontra o arquivo fxml
Arthur3 14 de ago. de 2020
Parent root = FXMLLoader.load(getClass().getResource(“LoginFXML.fxml”));
Essa linha só chama o FXML caso esteja na mesma pasta, mas e se estiver em uma anterior?, no caso login
Lucas_Camara 14 de ago. de 2020
Essa solução que passei resolvei a questão de encontrar o arquivo, porém, tinha gerado esse outro problema:
Caused by : java . lang . ClassNotFoundException : LoginFXMLController
Que foi resolvido quando vc fez isso:
fx : controller = “ br . com . mask . tarefas . login . layout . LoginFXMLController ”
Depois dessas alterações, ainda está sem funcionar?
Arthur3 14 de ago. de 2020
Sim… não resolveu
A classe que puxa eu deixei assim, como você falou:
package br.com.mask.tarefas.login;
import javafx.application.Application ;
import javafx.fxml.FXMLLoader ;
import javafx.scene.Parent ;
import javafx.scene.Scene ;
import javafx.stage.Stage ;
public class LoginSystem extends Application {
@Override
public void start ( Stage stage ) throws Exception {
Parent root = FXMLLoader . load ( getClass (). getResource ( "…/layout/LoginFXML.fxml" ));
Scene scene = new Scene ( root );
stage . setScene ( scene );
stage . show ();
}
public static void main ( String [] args ) {
launch ( args );
}
}
Arthur3 14 de ago. de 2020
e acaba dando essa pilha de erro
Exception in Application start method
java . lang . reflect . InvocationTargetException
at sun . reflect . NativeMethodAccessorImpl . invoke0 ( Native Method )
at sun . reflect . NativeMethodAccessorImpl . invoke ( NativeMethodAccessorImpl . java : 62 )
at sun . reflect . DelegatingMethodAccessorImpl . invoke ( DelegatingMethodAccessorImpl . java : 43 )
at java . lang . reflect . Method . invoke ( Method . java : 498 )
at com . sun . javafx . application . LauncherImpl . launchApplicationWithArgs ( LauncherImpl . java : 389 )
at com . sun . javafx . application . LauncherImpl . launchApplication ( LauncherImpl . java : 328 )
at sun . reflect . NativeMethodAccessorImpl . invoke0 ( Native Method )
at sun . reflect . NativeMethodAccessorImpl . invoke ( NativeMethodAccessorImpl . java : 62 )
at sun . reflect . DelegatingMethodAccessorImpl . invoke ( DelegatingMethodAccessorImpl . java : 43 )
at java . lang . reflect . Method . invoke ( Method . java : 498 )
at sun . launcher . LauncherHelper $ FXHelper . main ( LauncherHelper . java : 873 )
Caused by : java . lang . RuntimeException : Exception in Application start method
at com . sun . javafx . application . LauncherImpl . launchApplication1 ( LauncherImpl . java : 917 )
at com . sun . javafx . application . LauncherImpl . lambda $ launchApplication $ 1 ( LauncherImpl . java : 182 )
at java . lang . Thread . run ( Thread . java : 748 )
Caused by : java . lang . NullPointerException : Location is required .
at javafx . fxml . FXMLLoader . loadImpl ( FXMLLoader . java : 3207 )
at javafx . fxml . FXMLLoader . loadImpl ( FXMLLoader . java : 3175 )
at javafx . fxml . FXMLLoader . loadImpl ( FXMLLoader . java : 3148 )
at javafx . fxml . FXMLLoader . loadImpl ( FXMLLoader . java : 3124 )
at javafx . fxml . FXMLLoader . loadImpl ( FXMLLoader . java : 3104 )
at javafx . fxml . FXMLLoader . load ( FXMLLoader . java : 3097 )
at br . com . mask . tarefas . login . LoginSystem . start ( LoginSystem . java : 18 )
at com . sun . javafx . application . LauncherImpl . lambda $ launchApplication1 $ 8 ( LauncherImpl . java : 863 )
at com . sun . javafx . application . PlatformImpl . lambda $ runAndWait $ 7 ( PlatformImpl . java : 326 )
at com . sun . javafx . application . PlatformImpl . lambda $ null $ 5 ( PlatformImpl . java : 295 )
at java . security . AccessController . doPrivileged ( Native Method )
at com . sun . javafx . application . PlatformImpl . lambda $ runLater $ 6 ( PlatformImpl . java : 294 )
at com . sun . glass . ui . InvokeLaterDispatcher $ Future . run ( InvokeLaterDispatcher . java : 95 )
at com . sun . glass . ui . win . WinApplication . _runLoop ( Native Method )
at com . sun . glass . ui . win . WinApplication . lambda $ null $ 4 ( WinApplication . java : 186 )
… 1 more
Exception running application br . com . mask . tarefas . login . LoginSystem
C : \Users \Talita \Documents \NetBeansProjects \app - tarefas \nbproject \build - impl . xml : 1052 : The following error occurred while executing this line :
C : \Users \Talita \Documents \NetBeansProjects \app - tarefas \nbproject \build - impl . xml : 806 : Java returned : 1
FALHA NA CONSTRUÇÃO ( tempo total : 1 segundo )
Arthur3 14 de ago. de 2020 1 like
Consegui… criei uma URL e coloquei dentro do root, segue o codigo:
URL arquivoFXML = getClass().getResource("/br/com/mask/tarefas/login/layout/LoginFXML.fxml");
@ Override
public void start ( Stage stage ) throws Exception {
Parent root = FXMLLoader . load ( arquivoFXML );