相关疑难解决方法(0)

JavaFX表 - 如何添加组件?

我有一个swing项目,它使用许多JTable来显示从文本到面板到混合按钮和复选框的各种事物.我能够通过覆盖表格单元格渲染器来返回通用JComponents来做到这一点.我的问题是可以使用JavaFx制作类似的表格吗?

我想更新项目中的所有表,以使用JavaFx来支持手势.似乎TableView是要使用的JavaFx组件,我尝试添加按钮,但是在显示时它显示按钮的字符串值,而不是按钮本身.看起来我必须覆盖行工厂或单元工厂来做我想要的但是没有很多例子.这是我用作示例的代码,它将按钮显示为字符串.

import javax.swing.JButton;

import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.stage.Stage;

public class GestureEvents extends Application {

    private TableView<Person> table = new TableView<Person>();
    private final ObservableList<Person> data =
        FXCollections.observableArrayList(
            new Person("Jacob", "Smith", "jacob.smith@example.com","The Button"),
            new Person("Isabella", "Johnson", "isabella.johnson@example.com","The Button"),
            new Person("Ethan", "Williams", "ethan.williams@example.com","The Button"),
            new Person("Emma", "Jones", "emma.jones@example.com","The Button"),
            new Person("Michael", "Brown", "michael.brown@example.com","The Button")

        );

    public static …
Run Code Online (Sandbox Code Playgroud)

javafx tableview

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

javafx ×1

tableview ×1