I've been looking at tutorials, and I can't seem to get a table to populate. I'm using net beans and scenebuilder too. Any help would be greatly appreciated! been struggling for 5 hours.
Here is my code for the Controller
class:
public class FXMLDocumentController implements Initializable {
@FXML
private TableView<Table> table;
@FXML
private TableColumn<Table, String> countriesTab;
/**
* Initializes the controller class.
*/
ObservableList<Table> data = FXCollections.observableArrayList(
new Table("Canada"),
new Table("U.S.A"),
new Table("Mexico")
);
@Override
public void initialize(URL url, ResourceBundle rb) {
countriesTab.setCellValueFactory(new PropertyValueFactory<Table, String>("rCountry"));
table.setItems(data);
}
}
Here is my code for the Table
class Table {
public final SimpleStringProperty rCountry;
Table(String country){
this.rCountry = new SimpleStringProperty(country);
}
private SimpleStringProperty getRCountry(){
return this.rCountry;
}
}
Here is my main:
public class Assignment1 extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}