私はチュートリアルを見てきましたが、テーブルを作成できないようです。 私はネットビーンとシーンビルダも使用しています。 ご協力いただければ幸いです! 5時間苦労しました。ここでJavaFXテーブルの列、SceneBuilderにデータが入っていない
はController
クラスの私のコードです:ここでは
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);
}
}
はここTable
class Table {
public final SimpleStringProperty rCountry;
Table(String country){
this.rCountry = new SimpleStringProperty(country);
}
private SimpleStringProperty getRCountry(){
return this.rCountry;
}
}
ための私のコードで私のメインされていますPropertyValueFactory
については
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);
}
}
あなたはFXMLコード –