I am trying to create a table with some data but, Getting empty rows than needed.
The information I need is displayed and extra rows are showing how to remove those?
tried to keep it to height of the pane but not solved.
Table sample.java
public class TableSample extends Application {
TableView<Product> table;
@Override
public void start(Stage primaryStage) throws Exception {
TableColumn<Product,String> nameColoumn = new TableColumn<>("Name");
nameColoumn.setMinWidth(200);
nameColoumn.setCellValueFactory(new PropertyValueFactory<>("name"));
TableColumn<Product,Double> priceColoumn = new TableColumn<>("Price");
priceColoumn.setMinWidth(200);
priceColoumn.setCellValueFactory(new PropertyValueFactory<>("price"));
TableColumn<Product,Integer> quatityColoumn = new TableColumn<>("Quantity");
quatityColoumn.setMinWidth(200);
quatityColoumn.setCellValueFactory(new PropertyValueFactory<>("quatity"));
table=new TableView<>();
table.setItems(getProduct());
table.getColumns().addAll(nameColoumn,priceColoumn,quatityColoumn);
VBox vbox = new VBox();
vbox.getChildren().add(table);
Scene scene = new Scene(vbox);
primaryStage.setScene(scene);
primaryStage.show();
}
public ObservableList<Product> getProduct(){
ObservableList<Product> products =FXCollections.observableArrayList();
products.add(new Product("laptopt",55,22));
products.add(new Product("sjkad",56,52));
products.add(new Product("qqqqq",42,52));
products.add(new Product("ddd",25,42));
products.add(new Product("www",72,5225));
return products;
}
public static void main(String[] args) {
launch(args);
}
}