0

this is probably been answered before, quite possibly many times.

Totally fail to understand what i look for, and my java experience is about few weeks

I try to build application in javafx, I use scenebuilder, and i want table, some kind of grid component, which size i can declare dynamically.

Failed to figure how to add row or column or populate table with data: http://clip2net.com/s/jpGKh0

So, i went to scenebuilder generated Controller code, and it says:

@FXML
private TableColumn<?, ?> col2;

@FXML
private TableView<?> table;

@FXML
private TableColumn<?, ?> col1;

This <?> or <?,?> declarations.. what is it? How to use table, col1, col2 to bring a live to table?

Timo Junolainen
  • 294
  • 2
  • 13

1 Answers1

0

?: Is called the unbounded wildcard in java. It is a wildcard used in java generics

Example: List<?> myList.

Here ? is used to say that myList contains some kind of object that I don't care what type it is. Therefore, you cannot add to myList any object of any kind. Therefore, you cannot populate a TableView declared as TableView<?>, Since to populate a table view you have to add to the children list which would then be an ObservableList<?> which you cannot add to.

Therefore, you should know what you want to put in the table(say Students), and then declare the table as TableView. And then you columns will be say:

private TableColumn<Student, String> nameCol;
private TableColumn<Student, Integer> idCol;

Take a look at this tutorial: http://docs.oracle.com/javafx/2/ui_controls/table-view.htm

javaHunter
  • 1,097
  • 6
  • 9