答案 0 :(得分:-1)
需要编写自己的 TableCell 。 例如,我可以提供一个,根据存储的值,在单元格中显示不同的图片。在 setGraphic 方法中,您可以设置任何javaFX元素。
from statistics import mean
def average(lst):
lst = [float(x) for x in lst]
return mean(lst)
if __name__ == '__main__':
nums = []
run = True
while run:
new = int(input("Please input numbers and type 1234567 when you wish to find the average if the numbers inputted\n"))
if new == 1234567:
run = False
else:
nums.append(new)
print(nums)
print(average(nums))
此外,要在表中使用书面的TableCell,在设置表时需要添加:
public class IncreaseTableCell extends TableCell<Position, Boolean> {
public IncreaseTableCell() {
super();
}
public static Callback<TableColumn<Position, Boolean>, TableCell<Position, Boolean>>
getCellFactory() {
return e -> {
IncreaseTableCell cell = new IncreaseTableCell();
cell.setAlignment(Pos.CENTER);
return cell;
};
}
@Override
protected void updateItem(Boolean item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setGraphic(StructureGUI.getIcon(item ? "up" : "down"));
}
}