小编hos*_*ein的帖子

如何将文本字段插入javafx表视图标题?

我有一个简单的javafx样本tableView.我想在列标题标签下插入一个文本字段来过滤表数据.

我找到了一个例子,但它插入了文本字段而不是标题标签,而我想同时拥有标签和文本字段:

import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class TableWithTextHeaders extends Application {
    public static void main(String[] args) { launch(args); }

    @Override 
    public void start(Stage stage) {
        TableColumn firstNameCol = new TableColumn("First Name");
        firstNameCol.setCellValueFactory(new PropertyValueFactory<Person,String>("firstName"));
        TableColumn lastNameCol = new TableColumn("Last Name");
        lastNameCol.setCellValueFactory(new PropertyValueFactory<Person,String>("lastName"));
        TableColumn searchCol = new TableColumn<>();

        TableView table = new TableView();
        table.getColumns().addAll(firstNameCol, lastNameCol);
        table.setItems(FXCollections.observableArrayList(
            new Person("Jacob", "Smith"),
            new Person("Isabella", "Johnson"),
            new …
Run Code Online (Sandbox Code Playgroud)

java javafx-2

0
推荐指数
1
解决办法
4874
查看次数

标签 统计

java ×1

javafx-2 ×1