Page 1 of 2 12 LastLast
Results 1 to 20 of 33
  1. #1
    caraldur is offline Member
    Join Date
    Feb 2015
    Posts
    27
    Rep Power
    0

    Default Closing Pane in a javafx application

    Hello everyone,

    I am writing an inventory program using fxml and a controller class for add and removing parts from an inventory database. When the user click on the new part menuitem on the menubar the fxml file is displayed in the center pane of a borderpane. I want to close this pane after the user has successfully added a new part to the inventory database or clicked the cancel button. I'm having trouble figuring out how to close the add new part fxml once I have update my database or clicked the cancel button.

    Any help would be appreciated.

    -Fred

  2. #2
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    398
    Rep Power
    5

    Default Re: Closing Pane in a javafx application

    What are you trying to do, close the whole window/stage or do you just want to empty out the center section of the BorderPane?

  3. #3
    caraldur is offline Member
    Join Date
    Feb 2015
    Posts
    27
    Rep Power
    0

    Default Re: Closing Pane in a javafx application

    Quote Originally Posted by benji2505 View Post
    What are you trying to do, close the whole window/stage or do you just want to empty out the center section of the BorderPane?
    I want to empty the center section of the BorderPane, I tried to reference the main app class in my controller class but I get a null pointer error. Should I pass the Borderpane from my main app to the controller class and .setCenter(null)?

    update: I tried to pass a reference of the borderpane to my controller class and I am still getting a null pointer exception.

    Code from main App that displays the fxml in the center portion of the borderPane
    Java FX Code:
    MenuItem newPFM = new MenuItem("New PFM");
    		newPFM.setOnAction((actionEvent->{
    			try{
    				Pane newPFMForm = FXMLLoader.load(getClass().getResource("view/newPFM.fxml"));
    				BorderPane appArea = (BorderPane) root.getChildren().get(0);
    				appArea.setCenter(null);
    				newPFMController controller = new newPFMController();
    				controller.setBorderPane(appArea);
    				BorderPane.setAlignment(newPFMForm, Pos.CENTER);
    				appArea.setCenter(newPFMForm);
    				
    				
    			}catch(IOException e){
    				MessageClass message = new MessageClass();
    				
    				Alert a = new Alert(AlertType.ERROR);
    				String title = "Exception Dialog";
    				String header = "IO Exception!";
    				String content = "Error while loading new pfm window.";
    			    
    				
    				a = message.getIOExpectionMessage(a, title, header, content, e);
    				a.showAndWait();
    			}
    		}));
    Here is my code for my controller class
    Java FX Code:
    /**
     * Author: Fred Whitman
     * CopyRight 2017
     */
    package whitman.fa.inventory.controller;
    
    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.fxml.FXML;
    import javafx.scene.control.Alert;
    import javafx.scene.control.TextArea;
    import javafx.scene.control.TextField;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.control.Alert.AlertType;
    import whitman.fa.inventory.MessageClass;
    import whitman.fa.inventory.db.InventoryDB;
    import whitman.fa.inventory.model.PFM;
    
    /**
     * @author Fred
     *
     */
    public class newPFMController 
    {
    	@FXML TextField txtPFMName;
    	@FXML TextField txtPFMPartNumber;
    	@FXML TextField txtMinStock;
    	@FXML TextArea txtDescription;
    	
    	ObservableList<PFM> PFMNamesAndIDs = FXCollections.observableArrayList();
    	BorderPane mainBP;
    	private static final Logger log = LogManager.getLogger(newPFMController.class.getName());
    	
    	//DATABASE Variables
    	private final static String DB_CON = "mySQL server connection";
    	private final static String DB_USER = "mySQL server login";
    	private final static String DB_PW = "mySQL server password";
    		
    	@FXML
    	private void initialize(){
    		
    		getPFMNamesAndIDs();
    		PFMNameListener();
    		PFMPartNumberListener();
    	}
    	
    	private void getPFMNamesAndIDs(){
    		InventoryDB db = new InventoryDB(DB_CON,DB_USER,DB_PW);
    		PFMNamesAndIDs = db.getPFMNames();
    	}
    	
    	private void PFMNameListener(){
    		txtPFMName.focusedProperty().addListener((observable,oldValue,newValue)->
    		{
    			if(!newValue)
    			{	
    				for(PFM pfmNames : PFMNamesAndIDs)
    				{
    					log.info(pfmNames.getPartName()+"   "+ txtPFMName.getText());
    					if(pfmNames.getPartName().equals(txtPFMName.getText()))
    					{
    						txtPFMName.requestFocus();
    						txtPFMName.setText(null);
    						MessageClass message = new MessageClass();
    				
    						Alert a = new Alert(AlertType.WARNING);
    						String title = "Warning Dialog";
    						String header = "Duplicate PFM Name!";
    						String content = "You must using a different name for this PFM, because it's already in the database.";
    						String e ="";
    						a = message.getWarningMessage(a, title, header, content,e);
    						a.showAndWait();
    					}
    				}
    			}
    			
    		});
    	}
    	
    	private void PFMPartNumberListener(){
    		txtPFMPartNumber.focusedProperty().addListener((observable,oldValue,newValue)->
    		{
    			if(!newValue){
    				for(PFM pfmNames : PFMNamesAndIDs){
    					if(pfmNames.getPartNumber().equals(txtPFMPartNumber.getText())){
    						txtPFMPartNumber.requestFocus();
    						txtPFMPartNumber.setText(null);
    						MessageClass message = new MessageClass();
    						
    						Alert a = new Alert(AlertType.WARNING);
    						String title = "Warning Dialog";
    						String header = "Duplicate PFM Part Number!";
    						String content = "This PFM Part Number is already in the database.";
    						String e ="";
    						a = message.getWarningMessage(a, title, header, content,e);
    						a.showAndWait();
    					}
    				}
    			}
    		});
    		
    	}
    	
    	@FXML
    	public void handleSubmit(){
    		ObservableList<PFM> newPFM = FXCollections.observableArrayList();
    		newPFM.add(new PFM(txtPFMPartNumber.getText(),txtPFMName.getText(),"0",Integer.parseInt(txtMinStock.getText()),0));
    		InventoryDB db = new InventoryDB(DB_CON,DB_USER,DB_PW);
    		db.insertNewPFM(newPFM);
    		
    	}
    	
    	public void setBorderPane(BorderPane _mainBP){
    		mainBP = _mainBP;
    	}
    	
    	@FXML
    	public void handleCancel()
    	{
    		mainBP.setCenter(null);
    	}
    }

  4. #4
    caraldur is offline Member
    Join Date
    Feb 2015
    Posts
    27
    Rep Power
    0

    Default Re: Closing Pane in a javafx application

    I'm waiting for my post to be approved by the mod. I want to close the clear the center of the borderpane and not close the app. Once my post gets approved you'll see the my code for the main app and the controller class.
    Last edited by caraldur; 05-04-2017 at 03:39 PM.

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Closing Pane in a javafx application

    Quote Originally Posted by caraldur View Post
    I'm waiting for my post to be approved by the mod. I want to close the clear the center of the borderpane and not close the app. Once my post gets approved you'll see the my code for the main app and the controller class.
    Not certain what you're used to but no approval is required (or forthcoming). Post your questions and code. And please put the code between code tags (see BBcodes below). And you may want to read the forum guidelines.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  6. #6
    caraldur is offline Member
    Join Date
    Feb 2015
    Posts
    27
    Rep Power
    0

    Default Re: Closing Pane in a javafx application

    Stange, I received a message that my post need to be approved by a mod. I'll try again.

  7. #7
    caraldur is offline Member
    Join Date
    Feb 2015
    Posts
    27
    Rep Power
    0

    Default Re: Closing Pane in a javafx application

    Quote Originally Posted by benji2505 View Post
    What are you trying to do, close the whole window/stage or do you just want to empty out the center section of the BorderPane?
    I want to empty the center section of the BorderPane, I tried to reference the main app class in my controller class but I get a null pointer error. Should I pass the Borderpane from my main app to the controller class and .setCenter(null)?

    update: I tried to pass a reference of the borderpane to my controller class and I am still getting a null pointer exception.

    Code from main App that displays the fxml in the center portion of the borderPane
    Java FX Code:
    MenuItem newPFM = new MenuItem("New PFM");
    		newPFM.setOnAction((actionEvent->{
    			try{
    				Pane newPFMForm = FXMLLoader.load(getClass().getResource("view/newPFM.fxml"));
    				BorderPane appArea = (BorderPane) root.getChildren().get(0);
    				appArea.setCenter(null);
    				newPFMController controller = new newPFMController();
    				controller.setBorderPane(appArea);
    				BorderPane.setAlignment(newPFMForm, Pos.CENTER);
    				appArea.setCenter(newPFMForm);
    				
    				
    			}catch(IOException e){
    				MessageClass message = new MessageClass();
    				
    				Alert a = new Alert(AlertType.ERROR);
    				String title = "Exception Dialog";
    				String header = "IO Exception!";
    				String content = "Error while loading new pfm window.";
    			    
    				
    				a = message.getIOExpectionMessage(a, title, header, content, e);
    				a.showAndWait();
    			}
    		}));
    Here is my code for my controller class
    Java FX Code:
    /**
     * Author: Fred Whitman
     * CopyRight 2017
     */
    package whitman.fa.inventory.controller;
    
    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.fxml.FXML;
    import javafx.scene.control.Alert;
    import javafx.scene.control.TextArea;
    import javafx.scene.control.TextField;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.control.Alert.AlertType;
    import whitman.fa.inventory.MessageClass;
    import whitman.fa.inventory.db.InventoryDB;
    import whitman.fa.inventory.model.PFM;
    
    /**
     * @author Fred
     *
     */
    public class newPFMController 
    {
    	@FXML TextField txtPFMName;
    	@FXML TextField txtPFMPartNumber;
    	@FXML TextField txtMinStock;
    	@FXML TextArea txtDescription;
    	
    	ObservableList<PFM> PFMNamesAndIDs = FXCollections.observableArrayList();
    	BorderPane mainBP;
    	private static final Logger log = LogManager.getLogger(newPFMController.class.getName());
    	
    	//DATABASE Variables
    	private final static String DB_CON = "mySQL server connection";
    	private final static String DB_USER = "mySQL server login";
    	private final static String DB_PW = "mySQL server password";
    		
    	@FXML
    	private void initialize(){
    		
    		getPFMNamesAndIDs();
    		PFMNameListener();
    		PFMPartNumberListener();
    	}
    	
    	private void getPFMNamesAndIDs(){
    		InventoryDB db = new InventoryDB(DB_CON,DB_USER,DB_PW);
    		PFMNamesAndIDs = db.getPFMNames();
    	}
    	
    	private void PFMNameListener(){
    		txtPFMName.focusedProperty().addListener((observable,oldValue,newValue)->
    		{
    			if(!newValue)
    			{	
    				for(PFM pfmNames : PFMNamesAndIDs)
    				{
    					log.info(pfmNames.getPartName()+"   "+ txtPFMName.getText());
    					if(pfmNames.getPartName().equals(txtPFMName.getText()))
    					{
    						txtPFMName.requestFocus();
    						txtPFMName.setText(null);
    						MessageClass message = new MessageClass();
    				
    						Alert a = new Alert(AlertType.WARNING);
    						String title = "Warning Dialog";
    						String header = "Duplicate PFM Name!";
    						String content = "You must using a different name for this PFM, because it's already in the database.";
    						String e ="";
    						a = message.getWarningMessage(a, title, header, content,e);
    						a.showAndWait();
    					}
    				}
    			}
    			
    		});
    	}
    	
    	private void PFMPartNumberListener(){
    		txtPFMPartNumber.focusedProperty().addListener((observable,oldValue,newValue)->
    		{
    			if(!newValue){
    				for(PFM pfmNames : PFMNamesAndIDs){
    					if(pfmNames.getPartNumber().equals(txtPFMPartNumber.getText())){
    						txtPFMPartNumber.requestFocus();
    						txtPFMPartNumber.setText(null);
    						MessageClass message = new MessageClass();
    						
    						Alert a = new Alert(AlertType.WARNING);
    						String title = "Warning Dialog";
    						String header = "Duplicate PFM Part Number!";
    						String content = "This PFM Part Number is already in the database.";
    						String e ="";
    						a = message.getWarningMessage(a, title, header, content,e);
    						a.showAndWait();
    					}
    				}
    			}
    		});
    		
    	}
    	
    	@FXML
    	public void handleSubmit(){
    		ObservableList<PFM> newPFM = FXCollections.observableArrayList();
    		newPFM.add(new PFM(txtPFMPartNumber.getText(),txtPFMName.getText(),"0",Integer.parseInt(txtMinStock.getText()),0));
    		InventoryDB db = new InventoryDB(DB_CON,DB_USER,DB_PW);
    		db.insertNewPFM(newPFM);
    		
    	}
    	
    	public void setBorderPane(BorderPane _mainBP){
    		mainBP = _mainBP;
    	}
    	
    	@FXML
    	public void handleCancel()
    	{
    		mainBP.setCenter(null);
    	}
    }

  8. #8
    caraldur is offline Member
    Join Date
    Feb 2015
    Posts
    27
    Rep Power
    0

    Default Re: Closing Pane in a javafx application

    I just got the same message it read your post will be visible once it is reviewed by a moderator.

  9. #9
    caraldur is offline Member
    Join Date
    Feb 2015
    Posts
    27
    Rep Power
    0

    Default Re: Closing Pane in a javafx application

    Quote Originally Posted by benji2505 View Post
    What are you trying to do, close the whole window/stage or do you just want to empty out the center section of the BorderPane?
    I want to empty the center section of the BorderPane, I tried to reference the main app class in my controller class but I get a null pointer error. Should I pass the Borderpane from my main app to the controller class and .setCenter(null)?

    update: I tried to pass a reference of the borderpane to my controller class and I am still getting a null pointer exception.

    Code from main App that displays the fxml in the center portion of the borderPane
    Java FX Code:
    MenuItem newPFM = new MenuItem("New PFM");
    		newPFM.setOnAction((actionEvent->{
    			try{
    				Pane newPFMForm = FXMLLoader.load(getClass().getResource("view/newPFM.fxml"));
    				BorderPane appArea = (BorderPane) root.getChildren().get(0);
    				appArea.setCenter(null);
    				newPFMController controller = new newPFMController();
    				controller.setBorderPane(appArea);
    				BorderPane.setAlignment(newPFMForm, Pos.CENTER);
    				appArea.setCenter(newPFMForm);
    				
    				
    			}catch(IOException e){
    				MessageClass message = new MessageClass();
    				
    				Alert a = new Alert(AlertType.ERROR);
    				String title = "Exception Dialog";
    				String header = "IO Exception!";
    				String content = "Error while loading new pfm window.";
    			    
    				
    				a = message.getIOExpectionMessage(a, title, header, content, e);
    				a.showAndWait();
    			}
    		}));
    Here is my code for my controller class
    Java FX Code:
    /**
     * Author: Fred Whitman
     * CopyRight 2017
     */
    package whitman.fa.inventory.controller;
    
    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.fxml.FXML;
    import javafx.scene.control.Alert;
    import javafx.scene.control.TextArea;
    import javafx.scene.control.TextField;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.control.Alert.AlertType;
    import whitman.fa.inventory.MessageClass;
    import whitman.fa.inventory.db.InventoryDB;
    import whitman.fa.inventory.model.PFM;
    
    /**
     * @author Fred
     *
     */
    public class newPFMController 
    {
    	@FXML TextField txtPFMName;
    	@FXML TextField txtPFMPartNumber;
    	@FXML TextField txtMinStock;
    	@FXML TextArea txtDescription;
    	
    	ObservableList<PFM> PFMNamesAndIDs = FXCollections.observableArrayList();
    	BorderPane mainBP;
    	private static final Logger log = LogManager.getLogger(newPFMController.class.getName());
    	
    	//DATABASE Variables
    	private final static String DB_CON = "mySQL server connection";
    	private final static String DB_USER = "mySQL server login";
    	private final static String DB_PW = "mySQL server password";
    		
    	@FXML
    	private void initialize(){
    		
    		getPFMNamesAndIDs();
    		PFMNameListener();
    		PFMPartNumberListener();
    	}
    	
    	private void getPFMNamesAndIDs(){
    		InventoryDB db = new InventoryDB(DB_CON,DB_USER,DB_PW);
    		PFMNamesAndIDs = db.getPFMNames();
    	}
    	
    	private void PFMNameListener(){
    		txtPFMName.focusedProperty().addListener((observable,oldValue,newValue)->
    		{
    			if(!newValue)
    			{	
    				for(PFM pfmNames : PFMNamesAndIDs)
    				{
    					log.info(pfmNames.getPartName()+"   "+ txtPFMName.getText());
    					if(pfmNames.getPartName().equals(txtPFMName.getText()))
    					{
    						txtPFMName.requestFocus();
    						txtPFMName.setText(null);
    						MessageClass message = new MessageClass();
    				
    						Alert a = new Alert(AlertType.WARNING);
    						String title = "Warning Dialog";
    						String header = "Duplicate PFM Name!";
    						String content = "You must using a different name for this PFM, because it's already in the database.";
    						String e ="";
    						a = message.getWarningMessage(a, title, header, content,e);
    						a.showAndWait();
    					}
    				}
    			}
    			
    		});
    	}
    	
    	private void PFMPartNumberListener(){
    		txtPFMPartNumber.focusedProperty().addListener((observable,oldValue,newValue)->
    		{
    			if(!newValue){
    				for(PFM pfmNames : PFMNamesAndIDs){
    					if(pfmNames.getPartNumber().equals(txtPFMPartNumber.getText())){
    						txtPFMPartNumber.requestFocus();
    						txtPFMPartNumber.setText(null);
    						MessageClass message = new MessageClass();
    						
    						Alert a = new Alert(AlertType.WARNING);
    						String title = "Warning Dialog";
    						String header = "Duplicate PFM Part Number!";
    						String content = "This PFM Part Number is already in the database.";
    						String e ="";
    						a = message.getWarningMessage(a, title, header, content,e);
    						a.showAndWait();
    					}
    				}
    			}
    		});
    		
    	}
    	
    	@FXML
    	public void handleSubmit(){
    		ObservableList<PFM> newPFM = FXCollections.observableArrayList();
    		newPFM.add(new PFM(txtPFMPartNumber.getText(),txtPFMName.getText(),"0",Integer.parseInt(txtMinStock.getText()),0));
    		InventoryDB db = new InventoryDB(DB_CON,DB_USER,DB_PW);
    		db.insertNewPFM(newPFM);
    		
    	}
    	
    	public void setBorderPane(BorderPane _mainBP){
    		mainBP = _mainBP;
    	}
    	
    	@FXML
    	public void handleCancel()
    	{
    		mainBP.setCenter(null);
    	}
    }

  10. #10
    caraldur is offline Member
    Join Date
    Feb 2015
    Posts
    27
    Rep Power
    0

    Default Re: Closing Pane in a javafx application

    Below is the message a received when I tried the Post Quick Reply.


    Thank you for posting! Your post will not be visible until a moderator has approved it for posting.

  11. #11
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Closing Pane in a javafx application

    Well, I never remember my first posts getting approved by a mod. Especially since all of your posts are being posted and are visible. So I don't know what is going on. I have seen numerous posts by first time posters when no mods are logged in.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  12. #12
    caraldur is offline Member
    Join Date
    Feb 2015
    Posts
    27
    Rep Power
    0

    Default Re: Closing Pane in a javafx application

    Quote Originally Posted by jim829 View Post
    Well, I never remember my first posts getting approved by a mod. Especially since all of your posts are being posted and are visible. So I don't know what is going on. I have seen numerous posts by first time posters when no mods are logged in.

    Regards,
    Jim
    Do you think it could have something to do with my trying to post code using the code tags?

  13. #13
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    398
    Rep Power
    5

    Default Re: Closing Pane in a javafx application

    ok. Let's assume you have given your BorderPane an fx:id "myAwesomeBP" in the fxml file and you have announced it in the controller class with something like
    @FXML BorderPane myAwesomeBP;

    Then you can just do
    myAwesomeBP.setCenter(null);

    Alternatively you can get the collection of nodes from myAwesomeBP and remove any container that you might have used in your code when you created the center section (here "myVBoxContainer"):

    myAwesomeBP.getChildren().remove(myVBoxContainer);

    Typically one would find this code in some form of Button ActionHandler.

  14. #14
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Closing Pane in a javafx application

    I've approved the posts, but I have absolutely no idea why they got tagged like that.
    I can't see anything in your profile that might affect it.
    I would say it's the length of the post, but again I've never seen that before.
    We have had some random threads tagged as moderated over the past few weeks, but I've not seen posts tagged like that.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  15. #15
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    398
    Rep Power
    5

    Default Re: Closing Pane in a javafx application

    I am sure you have figured this out by now, just to close the thread:
    the issue is that the mainBP instance is not recognized as a node in the fxml file
    - make sure the BorderPane has an fx:id of mainBP. You can do that in SceneBuilder or in the fxml file itself
    - in line 33 of your above code, add the annotation @FXML.
    You should be in business after that.

  16. #16
    caraldur is offline Member
    Join Date
    Feb 2015
    Posts
    27
    Rep Power
    0

    Default Re: Closing Pane in a javafx application

    Quote Originally Posted by benji2505 View Post
    I am sure you have figured this out by now, just to close the thread:
    the issue is that the mainBP instance is not recognized as a node in the fxml file
    - make sure the BorderPane has an fx:id of mainBP. You can do that in SceneBuilder or in the fxml file itself
    - in line 33 of your above code, add the annotation @FXML.
    You should be in business after that.
    No luck. The problem is that the BorderPane doesn't exist in the newPFM.fxml. The FXML file has a pane that contains my form controls and I load that from the main app into the center of the BorderPane that I created in the main App class. I can add my Main App class if you want to see it but its almost 500 lines of code.

  17. #17
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    398
    Rep Power
    5

    Default Re: Closing Pane in a javafx application

    Do you get an exemption complaining that the JavaFX thread does not want to be disturbed?
    I have this setup quite often and I have no problem taking off nodes with something like

    Java FX Code:
    Platform.runLater(new Runnable(){
    					@Override
    					public void run(){
    						mainGridPane.getChildren().remove(node);
    					}

  18. #18
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    398
    Rep Power
    5

    Default Re: Closing Pane in a javafx application

    So you have a main stage made from a fxml file and the respective controller class (which is shown above). Now you're trying to get access from outside these 2 classes in order to add or remove graphics. That leads me to another question: do you have the controller instance injected into the Main App Class? The controller class is the only way to talk to the fxml file. You can get that instance with something like

    newPFMController myController = myFxmlLoaderInstance.getController();

    I think this is where the NPE might come from.
    Last edited by benji2505; 05-06-2017 at 01:00 AM.

  19. #19
    caraldur is offline Member
    Join Date
    Feb 2015
    Posts
    27
    Rep Power
    0

    Default Re: Closing Pane in a javafx application

    I'm creating my main stage, menubar and BorderPane at run time. When a menuitem is clicked the FXMLLoader loads the FXML file into a Pane with is then set to the center of the BorderPane that was created when the App was started.

    I tried to create a instance of the controller class but in my main app and then pass it to the controller class but I still get a NPE error.

  20. #20
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    398
    Rep Power
    5

    Default Re: Closing Pane in a javafx application

    unusual setup, but you should be able to get it to work.
    which reference is pointing to null? can you post the relevant code of the Main class? Only the relevant lines, not all 500 lines of code, if possible.

Page 1 of 2 12 LastLast

Similar Threads

  1. Make a JavaFX application work in JavaFXML
    By s22380 in forum JavaFX
    Replies: 2
    Last Post: 08-10-2016, 11:27 PM
  2. Dialog boxes closing on EVERY application.
    By Rtme in forum AWT / Swing
    Replies: 1
    Last Post: 05-17-2011, 07:54 PM
  3. Replies: 1
    Last Post: 01-11-2011, 07:11 AM
  4. How to intall my javaFX application on mobile
    By abuhmead1987 in forum JavaFX
    Replies: 1
    Last Post: 09-30-2010, 05:27 PM
  5. problem with playing video in javafx application
    By kiranblighty in forum JavaFX
    Replies: 1
    Last Post: 02-27-2010, 12:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •