JavaFX TableView/Column Null pointer exception

I am having trouble with Null pointers when trying to initiate Table population. I have my object from class called "Komponenta" which data I put in ObservableList and then try to show it in a TableView. I've tried this time to work with multiple fxml screens and for some reason it doesn't work with more than 1 .fxml. Test is a function that I call when a button is pressed on main.fxml so it loads a new one.

MainController.java

public ObservableList<Komponenta> komponente = FXCollections.observableArrayList(new Komponenta("Neki Tip", "Neki Proizvodac","Neki opis", 5)); @FXML private TableView<Komponenta> Tablica; @FXML private TableColumn<Komponenta,String> Tip; @FXML private TableColumn<Komponenta,String> Proizvodac; @FXML private TableColumn<Komponenta,String> Karakteristika; @FXML private TableColumn<Komponenta,Integer> Komada; @FXML private void test(ActionEvent event) throws IOException{     Node node=(Node) event.getSource();     Stage stage = (Stage) node.getScene().getWindow();     Parent root = (Pane)FXMLLoader.load(getClass().getResource("ElKomponenta.fxml"));     Scene scene = new Scene(root);     stage.setScene(scene);     stage.show();        } @FXML private void initialize() throws Exception  {     System.out.println(komponente.get(0).getKomada());     Tip.setCellValueFactory(new PropertyValueFactory<Komponenta, String>("tip"));     Proizvodac.setCellValueFactory(new PropertyValueFactory<Komponenta, String>("proizvodac"));     Karakteristika.setCellValueFactory(new PropertyValueFactory<Komponenta, String>("karakteristika"));     Komada.setCellValueFactory(new PropertyValueFactory<Komponenta, Integer>("komada"));     Tablica.setItems(komponente); } 

ElKomponenta.fxml

 <TableView fx:id="Tablica" prefHeight="603.0" prefWidth="889.0">                       <columns>                         <TableColumn fx:id="Tip" prefWidth="177.0" text="Tip" />                         <TableColumn fx:id="Proizvodac" minWidth="0.0" prefWidth="207.0" text="Proizvođač" />                           <TableColumn fx:id="Karakteristika" prefWidth="326.0" text="Karakteristike" />                           <TableColumn fx:id="Komada" minWidth="0.0" prefWidth="178.0" text="Komada" />                       </columns>                     </TableView> 

Error:

Caused by: java.lang.NullPointerException at application.MainController.initialize(MainController.java:62) ... 27 more 

Which is the line that first starts to setCellValueFactory.

Also if needed, Komponenta.java

public class Komponenta {  private String proizvodac; private String tip; private String karakteristika; private Integer komada;  public Komponenta(String a, String b, String c, Integer d){     this.tip = a;     this.proizvodac = b;     this.karakteristika = c;     this.komada = d; }  public String getProizvodac() {     return proizvodac; }  public void setProizvodac(String proizvodac) {     this.proizvodac = proizvodac; }  public String getTip() {     return tip; }  public void setTip(String tip) {     this.tip = tip; }  public String getKarakteristika() {     return karakteristika; }  public void setKarakteristika(String karakteristika) {     this.karakteristika = karakteristika; }  public Integer getKomada() {     return komada; }  public void setKomada(Integer komada) {     this.komada = komada; } 

}

Replay

Category: java Time: 2016-07-31 Views: 23

Related post

  • Null pointer Exception while Setting data to the TableView in JavaFX? 2016-01-15

    This question already has an answer here: What is a Null Pointer Exception, and how do I fix it? 12 answers When I am setting data to the ObservableList it throwing null pointer exception, I could not understand the problem. anyone please help me to

  • Unexpected Null Pointer exception in testing 2013-01-27

    My Test Class is global class Feedpost9 { // your methods here... static testMethod void testRest() { // set up the request object System.RestContext.request = new RestRequest(); RestContext.request.requestURI = '/v.9/notifications/preferences/ritesh

  • Null Pointer Exception add AccountId to WhatId for Task 2015-07-02

    Trying to build what I thought would be a simple trigger: when a task is created that is only related to a contact (WhoId = contact type, but WhatId = null), relate the task's WhatId to the contact's account. I know I can't just set the WhatId equal

  • Why am I getting NULL pointer exception in line 14 2015-10-21

    I have created a simple VF search page which returns a list of email addresses but getting NULL pointer exception in line 14 when I execute the search in VF page. Seeing that line 14 is the line which has NULL, I added a debug before that which retur

  • Null pointer exception in trigger.oldmap 2015-11-20

    I'm brand new at SF development but here's what I'm trying to do. I have a property custom object and it has some basic fields (Address, City, State, Zip). I have a Leasing Invoice custom object as well and when creating that I have a lookup for an a

  • Null pointer exception when parsing XML 2016-01-12

    DOM.Document xmlDOC = new DOM.Document(); xmlDOC.load(xmlstring); DOM.XMLNode rootElement = xmlDOC.getRootElement(); for(DOM.XMLNode xmlnodeobj:xmlDOC.getRootElement().getChildElements()){ For(Quote_line_item__c q:q1){ if(q.Name==xmlnodeobj.getChildE

  • Document listener brings a null pointer exception 2016-01-20

    I use a document listener and it brings me a null pointer exception . How could I stop this exception . I use this for search some content of a table. With using this I could search relevant content . Also this brings me a null pointer exception . Th

  • JPA Hibernate null pointer exception with OneToOne primary key/foreign key type relation 2016-02-10

    I'm having lots of trouble with a little prototype I'm trying to build. The problem involves two entities. But to understand it, I will need to describe a few others. In terms of the database structure, it can be described as follows: Person --------

  • Null Pointer Exception Error in a DoubleMatrix class 2016-02-11

    This question already has an answer here: What is a Null Pointer Exception, and how do I fix it? 12 answers I'm having trouble with a java problem. I get this error: Exception in thread "main" java.lang.NullPointerException at DoubleMatrix.getDi

  • Null pointer exception while printing using map fish 2016-07-20

    I am using mapfish plugin to print layers as a pdf but I keep getting null pointer exception.A snapshot of geoserver log is attached below 2016-07-20 14:57:50,753 ERROR [servlet.BaseMapServlet] - Error while generating PDF java.lang.NullPointerExcept

  • Sudoku solver null pointer exception 2008-10-20

    What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? --------------Solutions---

  • Null Pointer Exception On StackList 2008-10-20

    What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? --------------Solutions---

  • I m getting Null pointer exception on method onbindviewholder() 2008-10-20

    What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? --------------Solutions---

  • Overcoming Null Pointer Exception and Non Static Exception in Java 2008-10-20

    What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? --------------Solutions---

  • GETTING NULL POINTER EXCEPTION ERROR IN jTable 2008-10-20

    What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? --------------Solutions---

  • Null Pointer Exception in Recursive and Iterative Binary search 2008-10-20

    What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? --------------Solutions---

  • Null Pointer Exception, Attempt to invoke virtual method 2008-10-20

    What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? --------------Solutions---

  • Null Pointer Exception Error while running Android app 2008-10-20

    What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? --------------Solutions---

  • Null pointer exception on string array 2008-10-20

    What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? --------------Solutions---

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.381 (s). 13 q(s)