这是自定义列标题的代码:
private HBox createHeader(int index, String name){
HBox box = new HBox();
box.setAlignment(Pos.CENTER);
TextField headerTextField = new TextField(name);
headerTextField.textProperty().addListener((observable, oldValue, newValue) -> {
changeHeaderList(oldValue, newValue);
});
final ImageView crossImg = new ImageView("file:res/x.png");
crossImg.setFitHeight(20d);
crossImg.setFitWidth(20d);
crossImg.addEventHandler(MouseEvent.MOUSE_CLICKED, (MouseEvent event) -> {
selectedMatrix.getMatrixRowsArrList().forEach((MatrixRow mr) -> mr.getCells().remove(index));
selectedMatrix.setNumOfColumns(selectedMatrix.getNumOfColumns() - 1);
showMatrix(selectedMatrix.getName());
event.consume();
});
box.getChildren().addAll(headerTextField, crossImg);
return box;
}
这就是它的名称:
if (editBox.isSelected()) {
col.setSortable(false);
col.setGraphic(createHeader(i, m.getMatrixRowsArrList().get(0).getCells().get(i)));
它的外观如下:
全屏:
如何让TextField延伸到整个HBox?所以它像第一张照片一样全屏填充。感谢。
答案 0 :(得分:2)
您可以在HBox的createHeader方法中设置HGrow:
SELECT count(*), cdate
FROM tabl
GROUP BY YEAR(cdate), MONTH(cdate), DAY(cdate);