So basically in short terms i am doing an rpg type of game that has an inventory as a TableView and I want my items to be displayed there, but so far that doesn't seem to be working well. All the fx ids are set, yet whenever I run all I see is one column of empty boxes that can be selected.
This is the code for my TableViev:
public class InventoryScreenController implements Initializable {
@FXML private TableView<Items> table;
@FXML private Button equipButton;
@FXML private Button sortButton;
@FXML private TableColumn<Items, String> name;
@FXML private TableColumn<Items, Integer> value;
public final ObservableList<Items> list =
FXCollections.observableArrayList(new Items("huhhh",10));
@Override
public void initialize(URL url, ResourceBundle rb) {
name.setCellValueFactory(new PropertyValueFactory<Items, String>("Name"));
value.setCellValueFactory(new PropertyValueFactory<Items, Integer>("Value"));
table.setItems(list);
}
}
Code for the Items class:
public class Items {
private final SimpleStringProperty name;
private final SimpleIntegerProperty value;
public Items(String name, int value) {
this.name = new SimpleStringProperty(name);
this.value = new SimpleIntegerProperty(value);
}
}
This is how the output window looks like: