having trouble trying to filter search a tableview from textfield [duplicate]











up vote
0
down vote

favorite













This question already has an answer here:




  • What is a NullPointerException, and how do I fix it?

    12 answers



  • What is a stack trace, and how can I use it to debug my application errors?

    7 answers




 Caused by: java.lang.NullPointerException
at javafx.collections.transformation.TransformationList.<init>(TransformationList.java:65)
at javafx.collections.transformation.FilteredList.<init>(FilteredList.java:66)
at sample.Cust_Controller.srch(Cust_Controller.java:554)
at sample.Cust_Controller.initialize(Cust_Controller.java:603)


my textfield is called search



private void srch(){

columnFname.setCellValueFactory(cellData -> cellData.getValue().FirstNameProperty());
columnLname.setCellValueFactory(cellData -> cellData.getValue().LastNameProperty());

FilteredList<CustomerDetails> filteredData = new FilteredList<>(data, p -> true);

search.textProperty().addListener((observable, oldValue, newValue) -> {
filteredData.setPredicate((Predicate<? super CustomerDetails>) (CustomerDetails csd) -> {
// If filter text is empty, display all persons.
if (newValue == null || newValue.isEmpty()) {
return true;
}

// Compare first name and last name of every person with filter text.
String lowerCaseFilter = newValue.toLowerCase();

if (csd.getFirstName().toLowerCase().contains(lowerCaseFilter)) {
return true; // Filter matches first name.
} else if (csd.getLastName().toLowerCase().contains(lowerCaseFilter)) {
return true; // Filter matches last name.
}
return false; // Does not match.
});
});
// 3. Wrap the FilteredList in a SortedList.
SortedList<CustomerDetails> sortedData = new SortedList<>(filteredData);

// 4. Bind the SortedList comparator to the TableView comparator.
sortedData.comparatorProperty().bind(tableCustomer.comparatorProperty());

// 5. Add sorted (and filtered) data to the table.
tableCustomer.setItems(sortedData);

}


my customerdetails



public class CustomerDetails {
private final StringProperty custID;
private final StringProperty FirstName;
private final StringProperty LastName;
private final StringProperty Organization;
private final StringProperty Phone;
private final StringProperty Email;
private final StringProperty CusTypeID;
private final StringProperty CusTypeName;



public CustomerDetails(String custID, String FirstName, String LastName, String Organization, String Phone, String Email,String CusTypeID, String CusTypeName) {
this.custID = new SimpleStringProperty(custID);
this.FirstName = new SimpleStringProperty(FirstName);
this.LastName = new SimpleStringProperty(LastName);
this.Organization = new SimpleStringProperty(Organization);
this.Phone = new SimpleStringProperty(Phone);
this.Email = new SimpleStringProperty(Email);
this.CusTypeID = new SimpleStringProperty(CusTypeID);
this.CusTypeName = new SimpleStringProperty(CusTypeName);
}

public String getcustID() {
return (String)this.custID.get();
}

public String getFirstName() {
return (String)this.FirstName.get();
}

public String getLastName() {
return (String)this.LastName.get();
}

public String getOrganization() {
return (String)this.Organization.get();
}

public String getPhone() {
return (String)this.Phone.get();
}

public String getEmail() {
return (String)this.Email.get();
}

public String getCustTypeID() { return (String)this.CusTypeID.get();}

public String getCustTypeName() { return (String)this.CusTypeName.get();}

public void setcustID(String value) {
this.custID.set(value);
}

public void setFirstName(String value) {
this.FirstName.set(value);
}

public void setLastName(String value) {
this.LastName.set(value);
}

public void setOrganization(String value) {
this.Organization.set(value);
}

public void setPhone(String value) {
this.Phone.set(value);
}

public void setEmail(String value) {
this.Email.set(value);
}

public void setCusTypeID(String value) { this.CusTypeID.set(value);}

public void setCusTypeName(String value) { this.CusTypeName.set(value);}

public StringProperty custIDProperty() {
return this.custID;
}

public StringProperty FirstNameProperty() {
return this.FirstName;
}

public StringProperty LastNameProperty() {
return this.LastName;
}

public StringProperty FirstOrganizationProperty() {
return this.Organization;
}

public StringProperty PhoneProperty() {
return this.Phone;
}

public StringProperty EmailProperty() {
return this.Email;
}

public StringProperty CusTypeID() {return this.CusTypeID;}

public StringProperty CusTypeName() {return this.CusTypeName;}
}









share|improve this question















marked as duplicate by fabian java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 10 at 9:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • data seems to be null.
    – fabian
    Nov 10 at 9:50















up vote
0
down vote

favorite













This question already has an answer here:




  • What is a NullPointerException, and how do I fix it?

    12 answers



  • What is a stack trace, and how can I use it to debug my application errors?

    7 answers




 Caused by: java.lang.NullPointerException
at javafx.collections.transformation.TransformationList.<init>(TransformationList.java:65)
at javafx.collections.transformation.FilteredList.<init>(FilteredList.java:66)
at sample.Cust_Controller.srch(Cust_Controller.java:554)
at sample.Cust_Controller.initialize(Cust_Controller.java:603)


my textfield is called search



private void srch(){

columnFname.setCellValueFactory(cellData -> cellData.getValue().FirstNameProperty());
columnLname.setCellValueFactory(cellData -> cellData.getValue().LastNameProperty());

FilteredList<CustomerDetails> filteredData = new FilteredList<>(data, p -> true);

search.textProperty().addListener((observable, oldValue, newValue) -> {
filteredData.setPredicate((Predicate<? super CustomerDetails>) (CustomerDetails csd) -> {
// If filter text is empty, display all persons.
if (newValue == null || newValue.isEmpty()) {
return true;
}

// Compare first name and last name of every person with filter text.
String lowerCaseFilter = newValue.toLowerCase();

if (csd.getFirstName().toLowerCase().contains(lowerCaseFilter)) {
return true; // Filter matches first name.
} else if (csd.getLastName().toLowerCase().contains(lowerCaseFilter)) {
return true; // Filter matches last name.
}
return false; // Does not match.
});
});
// 3. Wrap the FilteredList in a SortedList.
SortedList<CustomerDetails> sortedData = new SortedList<>(filteredData);

// 4. Bind the SortedList comparator to the TableView comparator.
sortedData.comparatorProperty().bind(tableCustomer.comparatorProperty());

// 5. Add sorted (and filtered) data to the table.
tableCustomer.setItems(sortedData);

}


my customerdetails



public class CustomerDetails {
private final StringProperty custID;
private final StringProperty FirstName;
private final StringProperty LastName;
private final StringProperty Organization;
private final StringProperty Phone;
private final StringProperty Email;
private final StringProperty CusTypeID;
private final StringProperty CusTypeName;



public CustomerDetails(String custID, String FirstName, String LastName, String Organization, String Phone, String Email,String CusTypeID, String CusTypeName) {
this.custID = new SimpleStringProperty(custID);
this.FirstName = new SimpleStringProperty(FirstName);
this.LastName = new SimpleStringProperty(LastName);
this.Organization = new SimpleStringProperty(Organization);
this.Phone = new SimpleStringProperty(Phone);
this.Email = new SimpleStringProperty(Email);
this.CusTypeID = new SimpleStringProperty(CusTypeID);
this.CusTypeName = new SimpleStringProperty(CusTypeName);
}

public String getcustID() {
return (String)this.custID.get();
}

public String getFirstName() {
return (String)this.FirstName.get();
}

public String getLastName() {
return (String)this.LastName.get();
}

public String getOrganization() {
return (String)this.Organization.get();
}

public String getPhone() {
return (String)this.Phone.get();
}

public String getEmail() {
return (String)this.Email.get();
}

public String getCustTypeID() { return (String)this.CusTypeID.get();}

public String getCustTypeName() { return (String)this.CusTypeName.get();}

public void setcustID(String value) {
this.custID.set(value);
}

public void setFirstName(String value) {
this.FirstName.set(value);
}

public void setLastName(String value) {
this.LastName.set(value);
}

public void setOrganization(String value) {
this.Organization.set(value);
}

public void setPhone(String value) {
this.Phone.set(value);
}

public void setEmail(String value) {
this.Email.set(value);
}

public void setCusTypeID(String value) { this.CusTypeID.set(value);}

public void setCusTypeName(String value) { this.CusTypeName.set(value);}

public StringProperty custIDProperty() {
return this.custID;
}

public StringProperty FirstNameProperty() {
return this.FirstName;
}

public StringProperty LastNameProperty() {
return this.LastName;
}

public StringProperty FirstOrganizationProperty() {
return this.Organization;
}

public StringProperty PhoneProperty() {
return this.Phone;
}

public StringProperty EmailProperty() {
return this.Email;
}

public StringProperty CusTypeID() {return this.CusTypeID;}

public StringProperty CusTypeName() {return this.CusTypeName;}
}









share|improve this question















marked as duplicate by fabian java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 10 at 9:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • data seems to be null.
    – fabian
    Nov 10 at 9:50













up vote
0
down vote

favorite









up vote
0
down vote

favorite












This question already has an answer here:




  • What is a NullPointerException, and how do I fix it?

    12 answers



  • What is a stack trace, and how can I use it to debug my application errors?

    7 answers




 Caused by: java.lang.NullPointerException
at javafx.collections.transformation.TransformationList.<init>(TransformationList.java:65)
at javafx.collections.transformation.FilteredList.<init>(FilteredList.java:66)
at sample.Cust_Controller.srch(Cust_Controller.java:554)
at sample.Cust_Controller.initialize(Cust_Controller.java:603)


my textfield is called search



private void srch(){

columnFname.setCellValueFactory(cellData -> cellData.getValue().FirstNameProperty());
columnLname.setCellValueFactory(cellData -> cellData.getValue().LastNameProperty());

FilteredList<CustomerDetails> filteredData = new FilteredList<>(data, p -> true);

search.textProperty().addListener((observable, oldValue, newValue) -> {
filteredData.setPredicate((Predicate<? super CustomerDetails>) (CustomerDetails csd) -> {
// If filter text is empty, display all persons.
if (newValue == null || newValue.isEmpty()) {
return true;
}

// Compare first name and last name of every person with filter text.
String lowerCaseFilter = newValue.toLowerCase();

if (csd.getFirstName().toLowerCase().contains(lowerCaseFilter)) {
return true; // Filter matches first name.
} else if (csd.getLastName().toLowerCase().contains(lowerCaseFilter)) {
return true; // Filter matches last name.
}
return false; // Does not match.
});
});
// 3. Wrap the FilteredList in a SortedList.
SortedList<CustomerDetails> sortedData = new SortedList<>(filteredData);

// 4. Bind the SortedList comparator to the TableView comparator.
sortedData.comparatorProperty().bind(tableCustomer.comparatorProperty());

// 5. Add sorted (and filtered) data to the table.
tableCustomer.setItems(sortedData);

}


my customerdetails



public class CustomerDetails {
private final StringProperty custID;
private final StringProperty FirstName;
private final StringProperty LastName;
private final StringProperty Organization;
private final StringProperty Phone;
private final StringProperty Email;
private final StringProperty CusTypeID;
private final StringProperty CusTypeName;



public CustomerDetails(String custID, String FirstName, String LastName, String Organization, String Phone, String Email,String CusTypeID, String CusTypeName) {
this.custID = new SimpleStringProperty(custID);
this.FirstName = new SimpleStringProperty(FirstName);
this.LastName = new SimpleStringProperty(LastName);
this.Organization = new SimpleStringProperty(Organization);
this.Phone = new SimpleStringProperty(Phone);
this.Email = new SimpleStringProperty(Email);
this.CusTypeID = new SimpleStringProperty(CusTypeID);
this.CusTypeName = new SimpleStringProperty(CusTypeName);
}

public String getcustID() {
return (String)this.custID.get();
}

public String getFirstName() {
return (String)this.FirstName.get();
}

public String getLastName() {
return (String)this.LastName.get();
}

public String getOrganization() {
return (String)this.Organization.get();
}

public String getPhone() {
return (String)this.Phone.get();
}

public String getEmail() {
return (String)this.Email.get();
}

public String getCustTypeID() { return (String)this.CusTypeID.get();}

public String getCustTypeName() { return (String)this.CusTypeName.get();}

public void setcustID(String value) {
this.custID.set(value);
}

public void setFirstName(String value) {
this.FirstName.set(value);
}

public void setLastName(String value) {
this.LastName.set(value);
}

public void setOrganization(String value) {
this.Organization.set(value);
}

public void setPhone(String value) {
this.Phone.set(value);
}

public void setEmail(String value) {
this.Email.set(value);
}

public void setCusTypeID(String value) { this.CusTypeID.set(value);}

public void setCusTypeName(String value) { this.CusTypeName.set(value);}

public StringProperty custIDProperty() {
return this.custID;
}

public StringProperty FirstNameProperty() {
return this.FirstName;
}

public StringProperty LastNameProperty() {
return this.LastName;
}

public StringProperty FirstOrganizationProperty() {
return this.Organization;
}

public StringProperty PhoneProperty() {
return this.Phone;
}

public StringProperty EmailProperty() {
return this.Email;
}

public StringProperty CusTypeID() {return this.CusTypeID;}

public StringProperty CusTypeName() {return this.CusTypeName;}
}









share|improve this question
















This question already has an answer here:




  • What is a NullPointerException, and how do I fix it?

    12 answers



  • What is a stack trace, and how can I use it to debug my application errors?

    7 answers




 Caused by: java.lang.NullPointerException
at javafx.collections.transformation.TransformationList.<init>(TransformationList.java:65)
at javafx.collections.transformation.FilteredList.<init>(FilteredList.java:66)
at sample.Cust_Controller.srch(Cust_Controller.java:554)
at sample.Cust_Controller.initialize(Cust_Controller.java:603)


my textfield is called search



private void srch(){

columnFname.setCellValueFactory(cellData -> cellData.getValue().FirstNameProperty());
columnLname.setCellValueFactory(cellData -> cellData.getValue().LastNameProperty());

FilteredList<CustomerDetails> filteredData = new FilteredList<>(data, p -> true);

search.textProperty().addListener((observable, oldValue, newValue) -> {
filteredData.setPredicate((Predicate<? super CustomerDetails>) (CustomerDetails csd) -> {
// If filter text is empty, display all persons.
if (newValue == null || newValue.isEmpty()) {
return true;
}

// Compare first name and last name of every person with filter text.
String lowerCaseFilter = newValue.toLowerCase();

if (csd.getFirstName().toLowerCase().contains(lowerCaseFilter)) {
return true; // Filter matches first name.
} else if (csd.getLastName().toLowerCase().contains(lowerCaseFilter)) {
return true; // Filter matches last name.
}
return false; // Does not match.
});
});
// 3. Wrap the FilteredList in a SortedList.
SortedList<CustomerDetails> sortedData = new SortedList<>(filteredData);

// 4. Bind the SortedList comparator to the TableView comparator.
sortedData.comparatorProperty().bind(tableCustomer.comparatorProperty());

// 5. Add sorted (and filtered) data to the table.
tableCustomer.setItems(sortedData);

}


my customerdetails



public class CustomerDetails {
private final StringProperty custID;
private final StringProperty FirstName;
private final StringProperty LastName;
private final StringProperty Organization;
private final StringProperty Phone;
private final StringProperty Email;
private final StringProperty CusTypeID;
private final StringProperty CusTypeName;



public CustomerDetails(String custID, String FirstName, String LastName, String Organization, String Phone, String Email,String CusTypeID, String CusTypeName) {
this.custID = new SimpleStringProperty(custID);
this.FirstName = new SimpleStringProperty(FirstName);
this.LastName = new SimpleStringProperty(LastName);
this.Organization = new SimpleStringProperty(Organization);
this.Phone = new SimpleStringProperty(Phone);
this.Email = new SimpleStringProperty(Email);
this.CusTypeID = new SimpleStringProperty(CusTypeID);
this.CusTypeName = new SimpleStringProperty(CusTypeName);
}

public String getcustID() {
return (String)this.custID.get();
}

public String getFirstName() {
return (String)this.FirstName.get();
}

public String getLastName() {
return (String)this.LastName.get();
}

public String getOrganization() {
return (String)this.Organization.get();
}

public String getPhone() {
return (String)this.Phone.get();
}

public String getEmail() {
return (String)this.Email.get();
}

public String getCustTypeID() { return (String)this.CusTypeID.get();}

public String getCustTypeName() { return (String)this.CusTypeName.get();}

public void setcustID(String value) {
this.custID.set(value);
}

public void setFirstName(String value) {
this.FirstName.set(value);
}

public void setLastName(String value) {
this.LastName.set(value);
}

public void setOrganization(String value) {
this.Organization.set(value);
}

public void setPhone(String value) {
this.Phone.set(value);
}

public void setEmail(String value) {
this.Email.set(value);
}

public void setCusTypeID(String value) { this.CusTypeID.set(value);}

public void setCusTypeName(String value) { this.CusTypeName.set(value);}

public StringProperty custIDProperty() {
return this.custID;
}

public StringProperty FirstNameProperty() {
return this.FirstName;
}

public StringProperty LastNameProperty() {
return this.LastName;
}

public StringProperty FirstOrganizationProperty() {
return this.Organization;
}

public StringProperty PhoneProperty() {
return this.Phone;
}

public StringProperty EmailProperty() {
return this.Email;
}

public StringProperty CusTypeID() {return this.CusTypeID;}

public StringProperty CusTypeName() {return this.CusTypeName;}
}




This question already has an answer here:




  • What is a NullPointerException, and how do I fix it?

    12 answers



  • What is a stack trace, and how can I use it to debug my application errors?

    7 answers








java sql javafx filter scenebuilder






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 9:49









fabian

49.9k115170




49.9k115170










asked Nov 10 at 8:10









a p

83




83




marked as duplicate by fabian java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 10 at 9:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by fabian java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 10 at 9:50


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • data seems to be null.
    – fabian
    Nov 10 at 9:50


















  • data seems to be null.
    – fabian
    Nov 10 at 9:50
















data seems to be null.
– fabian
Nov 10 at 9:50




data seems to be null.
– fabian
Nov 10 at 9:50

















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff