자습서를 살펴 봤는데 테이블을 채울 수없는 것 같습니다. net beans와 scenebuilder도 사용하고 있습니다. 도움이 될 것입니다. 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);
}
}
당신은 –