0

I am new in Javafx programming with java for graphic interfaces, and after research for possible solutions, i still have the problem

I've got this code in my Main Javafx App which extends Application

public void initRootLayout() throws IOException {
            FXMLLoader loader;
            Parent rootLayout;

            loader = new FXMLLoader();          
            loader.setLocation(getClass().getResource("/fiec/dst/seer/screen/login/login.fxml"));       
            rootLayout = loader.load();
            LoginController = (loginFXMLController)loader.getController();
            // Show the scene containing the root layout.
            Scene scene = new Scene(rootLayout);
            primaryStage.setScene(scene);
            primaryStage.setMaximized(false);
            primaryStage.setResizable(false);
            primaryStage.show();


    }

LoginController is an instance of loginFXMLController which is the controller of fxml file that displays a login interface (user and password).

I don't know if i'm in the right path, but i have a method in Main class that needs to check if user and password are corrects(these attributes are in loginFXMLController), as you may see, first i call load method, and i need to ask constantly the values of user and password provided from LoginController.

initRootLayout is called in start method of Main Application

    @Override
    public void start(Stage primaryStage) throws IOException {

        this.primaryStage = primaryStage;
        this.primaryStage.setTitle("System");
        initRootLayout();
    }

I need help, because with these i'm getting the exception: java.lang.NullPointerException when i call attributes from LoginController

This is de StackTrace :

java.lang.NullPointerException
at fiec.dst.seer.main.RFIDReader.messageReceived(RFIDReader.java:323)
at org.llrp.ltk.net.LLRPIoHandlerAdapterImpl.messageReceived(LLRPIoHandlerAdapterImpl.java:109)
at org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageReceived(AbstractIoFilterChain.java:570)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53)
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648)
at org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput.flush(SimpleProtocolDecoderOutput.java:58)
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:180)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53)
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648)
at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:220)
at org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
at java.lang.Thread.run(Unknown Source)

MainApp extends from Application and implements LLRPEndpoint LLRPEndpoint contains methods to communicate with objects with RFID tags

This problem occurs when i try to get attribute from loginFXMLController (user and password)

  • 1
    [Edit] your question to include the complete [stack trace](http://stackoverflow.com/q/3988788/2775450), and identify the line in the code that is throwing the null pointer exception. – James_D Mar 10 '17 at 20:13
  • Do you have "fx:controller" attribute in your main container definition in login.fxml? It looks like this "fx:controller=loginFXMLController". – Rinat Mar 10 '17 at 20:36
  • @James_D I updated the description, thanks in advance – Developer FIEC Mar 13 '17 at 14:41
  • The code you posted has nothing to do with the stack trace. – James_D Mar 13 '17 at 14:50

0 Answers0