0
javafx.scene.control.cell.PropertyValueFactory getCellDataReflectively
WARNING: Can not retrieve property 'date' in PropertyValueFactory: javafx.scene.control.cell.PropertyValueFactory@27fe7b49 with provided class type: class sample.Customer
java.lang.IllegalStateException: Cannot read from unreadable property date

Here is my code:


package sample;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
public class Search implements Initializable
{
    @FXML
    TextField name;
    String User_Label;
    @FXML
    private ComboBox<String> choice_box;
    @FXML private TableView<Customer> tableView;
    @FXML private TableColumn<Customer,String> col_name;
    @FXML private TableColumn<Customer,String> col_cnic;
    @FXML private TableColumn<Customer,String> col_bus;
    @FXML private TableColumn<Customer,String> col_date;
    @FXML private TableColumn<Customer,String> col_route;

    private final ObservableList<Customer> data
            = FXCollections.observableArrayList(
            new Customer("Jacob", "45502", "29-1-10","Sukkur","Barca"),
            new Customer("Jacob", "45502", "29-1-10","Sukkur","Barca"),
            new Customer("Jacob", "45502", "29-1-10","Sukkur","Barca"),
            new Customer("Jacob", "45502", "29-1-10","Sukkur","Barca"),
            new Customer("Jacob", "45502", "29-1-10","Sukkur","Barca")
    );

    private ObservableList<String> choice = FXCollections.observableArrayList("Name","CNIC");
    public void show(String user)
    {
        this.User_Label = user;
    }

    @Override
    public void initialize(URL location, ResourceBundle resources)
    {
        col_name.setCellValueFactory(new PropertyValueFactory<Customer,String>("Name"));
        col_route.setCellValueFactory(new PropertyValueFactory<Customer,String>("Route"));
        col_bus.setCellValueFactory(new PropertyValueFactory<Customer,String>("Bus"));
        col_cnic.setCellValueFactory(new PropertyValueFactory<Customer,String>("Cnic"));
        col_date.setCellValueFactory(new PropertyValueFactory<Customer,String>("date"));


        choice_box.setItems(choice);
        tableView.setItems(data);
    }
    public void back(ActionEvent ae) throws IOException
    {
                ((Node)ae.getSource()).getScene().getWindow().hide();
                Stage primaryStage = new Stage();
                FXMLLoader loader = new FXMLLoader();
                Pane root = loader.load(getClass().getResource("Menu.fxml").openStream());

                Dashboard dashboard = loader.getController();
                dashboard.show(User_Label);

                Scene scene = new Scene(root);
                primaryStage.setScene(scene);
                primaryStage.show();
    }
    public void search_data(ActionEvent ae)
    {
        System.out.println(name.getText()+choice_box.getValue());

    }
}

Customer_Class


package sample;

import javafx.beans.property.SimpleStringProperty;
public class Customer
{
    SimpleStringProperty name;
    SimpleStringProperty cnic;
    SimpleStringProperty date;
    SimpleStringProperty route;
    SimpleStringProperty bus;

    Customer(String name,String cnic,String date,String route,String bus)
    {
        this.bus = new SimpleStringProperty(bus);
        this.cnic = new SimpleStringProperty(cnic);
        this.route = new SimpleStringProperty(route);
        this.name = new SimpleStringProperty(name);
        this.date = new SimpleStringProperty(date);
    }

    public String getName() {
        return name.get();
    }

    public SimpleStringProperty nameProperty() {
        return name;
    }

    public void setName(String name) {
        this.name.set(name);
    }

    public String getCnic() {
        return cnic.get();
    }

    public SimpleStringProperty cnicProperty() {
        return cnic;
    }

    public void setCnic(String cnic) {
        this.cnic.set(cnic);
    }

    public String getData() {
        return date.get();
    }

    public SimpleStringProperty dataProperty() {
        return date;
    }

    public void setData(String data) { this.date.set(data); }

    public String getRoute() {
        return route.get();
    }

    public SimpleStringProperty routeProperty() {return route;}

    public void setRoute(String route) {
        this.route.set(route);
    }

    public String getBus() {
        return bus.get();
    }

    public SimpleStringProperty busProperty() {
        return bus;
    }

    public void setBus(String bus) {
        this.bus.set(bus);
    }
}

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257

0 Answers0