Tag: tableview

Javafx tableview包含来自多个类的数据

我用1类不同的数据填充我的tableview没有问题。 但是对于我来说,多个class级并不适用。 知道如何解决这个问题吗? 我在stackoverflow上检查了类似的问题。 但他们都不能帮助我。 如果您对“Callback”类提出任何建议,请向我提供完整的导入,因为那里有几个Callback类。 public class MainViewController implements Initializable { @FXML private TableColumn colErledigt; @FXML private TableColumn colPrioritaet; @FXML private TableColumn colBeschreibung; @FXML private TableColumn colProjekt; @FXML private TableView tblView; public final void initialize(final URL location, final ResourceBundle resources) { initializeTableElements(); } public final void initializeTableElements() { colBeschreibung .setCellValueFactory(new PropertyValueFactory(“description”)); colPrioritaet .setCellValueFactory(new PropertyValueFactory(“priority”)); […]

JavaFX TableView动态列和数据值

我正在使用JavaFX使用简单的CSV查看器测试自己,并且我坚持填充表数据。 我确实动态创建列,但数据值是不行的。 我在网上搜索并找到了几种方法但是所有方法都包括带有自定义类(包括get / set)的ObservableList,它在CSV查看器中必须是动态的(CSV可以有任意数量的列,这意味着任意数量的数据值)。 例: List columns; List<List> data; /* Fills ‘columns’ and ‘data’ */ parseCSV(“C:/list.csv”); int columnIndex = 0; TableColumn [] tableColumns = new TableColumn[columns.size()]; for(String columName : columns) { tableColumns[columnIndex++] = new TableColumn(columName); } table1.getColumns().addAll(tableColumns); for(List dataList : data) { table1.setItems(dataList); // Requires an ObservableList! }

设置JavaFX TableView Cells的字体颜色?

在我的Java桌面应用程序中,我有一个包含3列的JavaFX表。 我想将第3列的字体颜色设置为红色。 我根本无法设置Tableb的字体颜色。 我查看了CSS,但没有找到任何东西。 有没有办法用CSS做到这一点? 我也寻找setFont(),希望以这种方式设置它。 空空如也。 我甚至无法想办法在某个单元格上设置某些东西。 TableView myTable = new TableView(); ObservableList myTableData = FXCollections.observableArreyList( new TableData(“data”, “data”, “data”), new TableData(“data”, “data”, “data”)); TableColumn firstColumn = new TableColumn(“First Column”); firstColumn.setProperty(“one”); TableColumn secondColumn = new TableColumn(“Second Column”); secondColumn .setProperty(“two”); TableColumn thirdColumn = new TableColumn(“Third Column”); thirdColumn .setProperty(“three”); myTable.setItems(myTableData); myTable.getColumns.addAll(firstColumn, secondColumn, thirdColumn); 我怎么能做到这一点? 如何设置字体颜色? 任何帮助将不胜感激。

如何绕过JavaFX的TableView“占位符”?

JavaFX的TableView有一个占位符属性,它基本上是一个Node ,只要它是空的就会在TableView显示。 如果此属性设置为null(其默认值),则它将显示为Label或其他基于文本的Node ,其中显示“表中没有内容”。 但是如果表中有任何数据行,则占位符Node消失,并且TableView的整个垂直空间将填充行,如果没有足够的数据填充整个表,则包括空行。 即使表是空的 ,这些空行也是我想要的。 换句话说,我根本不想使用占位符。 有谁知道我怎么做到这一点? 我宁愿不做什么事情就像在TableView放一个看起来很空的行一样。

从JavaFX TableView获取所选项目

如何从JavaFX中的TableView获取所选项? 我目前正在使用 ObservableList selectedItems = taview.getSelectionModel().getSelectedItems(); 但这并没有返回选择模型中的一个选定项目。

JavaFX tableview颜色

我需要创建具有多色行的JavaFx TableView(color1用于低优先级,color2用于中等优先级等)。 我创建了CellFactory public class TaskCellFactory implements Callback { @Override public TableCell call(TableColumn p) { TableCell cell = new TableCell() { @Override public void updateItem(Object item, boolean empty) { super.updateItem(item, empty); setText(empty ? null : getString()); setGraphic(null); TableRow currentRow = getTableRow(); Task currentTask = currentRow == null ? null : (Task)currentRow.getItem(); if(currentTask != null){ Priority […]

如何正确使用PropertyValueFactory?

我正在尝试使用TableView创建一个表,并根据User对象列表以编程方式填充它。 User有三个变量, nameProperty (String), rankProperty (Enum称为Rank)和netMeritsProperty (int)。 这些都存储在SimpleStringProperty对象中。 我的问题是数据不会出现在实际的表中,如下所示: 这是我的表格代码。 我不明白的是什么? TableColumn name = new TableColumn(“Name”); name.setCellValueFactory(new PropertyValueFactory(“nameProperty”)); TableColumn rank = new TableColumn(“Rank”); rank.setCellValueFactory(new PropertyValueFactory(“rankProperty”)); TableColumn netMerits = new TableColumn(“Net Merits”); netMerits.setCellValueFactory(new PropertyValueFactory(“netMeritsProperty”)); userTable.getColumns().addAll(name, rank, netMerits);

JavaFX在多个页面上打印tableview

所以,我的问题是我需要打印我的tableview的内容,但我有很多项目,它只打印其中的前23个。 我已经在这里找到了一些解决方案,遗憾的是它们并没有多大帮助。 这是我的打印方法: @FXML private void printIt() { Printer printer = Printer.getDefaultPrinter(); PageLayout pageLayout = printer.createPageLayout(Paper.A4, PageOrientation.LANDSCAPE, Printer.MarginType.DEFAULT); double scaleX = pageLayout.getPrintableWidth() / logBookTable.getBoundsInParent().getWidth(); double scaleY = pageLayout.getPrintableHeight() / logBookTable.getBoundsInParent().getHeight(); logBookTable.getTransforms().add(new Scale(scaleX, scaleY)); PrinterJob job = PrinterJob.createPrinterJob(); if (job != null) { boolean successPrintDialog = job.showPrintDialog(dialogStage); if(successPrintDialog){ boolean success = job.printPage(pageLayout,logBookTable); if (success) { job.endJob(); […]

如何将Image添加到JavaFx TableView列中

我正在尝试找到一种方法将图像添加到JavaFx TableView列,该列包含通过hibernate从H2数据库填充的其他列中的数据。 TableView是在JavaFx Scene Builder中设计的。 到目前为止,这是我设法组建的: 控制器类: public class HomeController implements Initializable { @FXML private TableView KIWI_TABLE; @FXML private TableColumn KiwiId; @FXML private TableColumn Kiwi; public ObservableList data; // Initializes the controller class. @Override public void initialize(URL url, ResourceBundle rb) { KiwiId.setCellFactory(new Callback<TableColumn, TableCell>() { @Override public TableCell call(TableColumn param) { //Set up the ImageView […]

JavaFX:CheckBoxTableCell在用户检查checkBox时获取ActionEvent

我想在用户选中或取消选中tableView中的复选框时触发方法或操作。 当用户使用checkBox时,不会触发coursData.addListener(…)。 这是我编译的代码,窗口显示带有复选框的tableView。 package testCheckBox2; import javafx.application.Application; import javafx.beans.InvalidationListener; import javafx.beans.Observable; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ButtonBase; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.cell.CheckBoxTableCell; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.stage.Stage; public class CheckBoxTableCellTest extends Application { private TableView […]