java - 在 javafx 中获得比需要更多的行数。如何解决这个问题?
问题描述
我正在尝试创建一个包含一些数据的表,但是,得到的空行比需要的多。
显示了我需要的信息,并且额外的行显示了如何删除这些信息?
试图将其保持在窗格的高度但未解决。
表样例.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);
}
}
解决方案
推荐阅读
- spss - 向数据添加新案例的语法
- linux - 如何列出包含特定字符串的文件名
- powershell - 使用 PowerShell 生成整个 D: Drive 的报告
- java - 在 Java 中将一些特定的日期格式化程序定义为枚举的成员
- jquery - 如何在未选择单选按钮时显示 jQuery 警报?
- javascript - 隐藏/删除谷歌图表中的 y 刻度
- sql - SQL 函数:结果为空
- python - 如何在 Django 中使用相对 URL 从“/media/”调用图像?
- sql - Sum 然后在一个 VIEW 中按子句划分为一个组
- java - Java 程序未正确输出 - VectorStack