带复选框的 Javafx 8 Tableview 选择

2023-11-30

我已经设置了一个启用多选的表视图,并尝试将插入列中的复选框的侦听器附加到表的选择模型。

checkBoxTableColumn.setCellValueFactory(
            cellData -> {
                CheckBox checkBox = new CheckBox();
                ObjectProperty<CheckBox> sop = new SimpleObjectProperty<CheckBox>();
                sop.setValue(checkBox);
                sop.getValue().setText("");



                sop.getValue().selectedProperty().addListener(
                        (obsv, oldv, newv) -> {
                            ArrayList<Job> tempSelectionArray = new ArrayList<>();

                            if(newv.booleanValue()){
                                tempSelectionArray.addAll(jobTableView.getSelectionModel().getSelectedItems().stream().collect(Collectors.toList()));
                                this.jobTableView.getSelectionModel().clearSelection();
                                for(Job job: tempSelectionArray){
                                    jobTableView.getSelectionModel().select(job);
                                }

                                tempSelectionArray.clear();
                            }
                            else{
                                tempSelectionArray.addAll(this.jobTableView.getSelectionModel().getSelectedItems().stream().collect(Collectors.toList()));
                                this.jobTableView.getSelectionModel().clearSelection();
                                tempSelectionArray.remove(getJobTableView().getFocusModel().getFocusedItem());
                                for(Job job: tempSelectionArray){
                                    this.jobTableView.getSelectionModel().select(job);
                                }
                                tempSelectionArray.clear();
                            }
                        }
                );
                ObservableValue<CheckBox> ov = sop;

                return ov;
            }

但这不会改变桌子的选择。

按法官所述编辑

        checkBoxTableColumn.setCellFactory(new Callback<TableColumn<Job, Boolean>, TableCell<Job, Boolean>>() {
        @Override
        public TableCell<Job, Boolean> call(TableColumn<Job, Boolean> param) {
            return new CheckBoxCell(jobTableView);


        }
    });

复选框单元格如下

class CheckBoxCell extends TableCell<Job, Boolean>{
private CheckBox checkBox;
private TableView<Job> jobTableView;

public CheckBoxCell(TableView<Job> tableView){
    this.jobTableView = tableView;
}
@Override
public void updateItem(Boolean item, boolean empty) {
    super.updateItem(item, empty);

    checkBox = new CheckBox();
    setGraphic(checkBox);

    checkBox.selectedProperty().addListener(
            (obsv, oldv, newv) -> {
                ArrayList<Job> tempSelectionArray = new ArrayList<>();

                if(newv.booleanValue()){
                    tempSelectionArray.addAll(jobTableView.getSelectionModel().getSelectedItems().stream().collect(Collectors.toList()));
                    this.jobTableView.getSelectionModel().clearSelection();
                    for(Job job: tempSelectionArray){
                        jobTableView.getSelectionModel().select(job);
                    }

                    tempSelectionArray.clear();
                }
                else{
                    tempSelectionArray.addAll(this.jobTableView.getSelectionModel().getSelectedItems().stream().collect(Collectors.toList()));
                    this.jobTableView.getSelectionModel().clearSelection();
                    tempSelectionArray.remove(jobTableView.getFocusModel().getFocusedItem());
                    for(Job job: tempSelectionArray){
                        this.jobTableView.getSelectionModel().select(job);
                    }
                    tempSelectionArray.clear();
                }
            }
    );
}

}

这次监听器不起作用了......

edit-#2

在控制器的初始化方法中:

        jobTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);


    checkBoxTableColumn.setEditable(true);
    checkBoxTableColumn.setCellValueFactory(
            new PropertyValueFactory<Job, Boolean>("isContextSelected")
    );

    checkBoxTableColumn.setCellFactory(
            new Callback<TableColumn<Job, Boolean>, TableCell<Job, Boolean>>() {
                @Override
                public TableCell<Job, Boolean> call(TableColumn<Job, Boolean> param) {
                    return new CheckBoxTableCell<Job, Boolean>(){
                        {
                            setAlignment(Pos.CENTER);
                        }

                        @Override
                        public void updateItem(Boolean item, boolean empty){
                            if(!empty){
                                TableRow row = getTableRow();

                                if(row != null){
                                    Integer rowNumber = row.getIndex();
                                    TableView.TableViewSelectionModel sm = getTableView().getSelectionModel();

                                    if(item){
                                        sm.select(rowNumber);

                                    }
                                    else{
                                        sm.clearSelection(rowNumber);

                                    }
                                }
                            }
                            super.updateItem(item, empty);
                        }
                    };
                }
            }
    );

工作类别:

    private  BooleanProperty isContextSelected;
    public BooleanProperty isContextSelectedProperty() {
    return isContextSelected;
    }

编辑 - 忽略不必要的部分。按要求的整个代码: 控制器:

 package BillControl.view;

import BillControl.Controller.PopulateView;
import BillControl.Controller.Validator;
import BillControl.MainApp;
import BillControl.model.Article;
import BillControl.model.Job;
import javafx.beans.property.*;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.scene.control.cell.CheckBoxTableCell;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Stage;
import javafx.util.Callback;


import java.util.ArrayList;
import java.util.TreeSet;


public class ArticleJobAssignmentController {
    private Article article;
    private Stage jobAssignStage;
    private boolean okClicked = false;
    private MainApp mainApp;
    ArrayList<Job> selectedJobList = new ArrayList<>();
    private ObservableList<Job> masterJobList = FXCollections.observableArrayList();
    private ObservableList<Job> currentJobList = FXCollections.observableArrayList();
    private ObservableList<Job> articleEngagementList = FXCollections.observableArrayList();
    private TreeSet rowIndices = new TreeSet();
@FXML
private Label articleNameLabel;
@FXML
private Label noOfJobsLabel;
@FXML
private Button okButton;
@FXML
private Button cancelButton;
@FXML
private Label errorLabel;



@FXML
private TableView<Job> jobTableView;
@FXML
private TableColumn<Job, Boolean> checkBoxTableColumn;
@FXML
private TableColumn<Job, String> jobNameColumn;
@FXML
private TableColumn<Job, String> clientNameColumn;
@FXML
private TableColumn<Job, Integer> noOfArticlesColumn;
@FXML
private TableColumn<Job, String> alreadyEngagedColumn;


public ArticleJobAssignmentController(){

}

public void initialize(){


    errorLabel.setVisible(false);
    jobTableView.setEditable(true);
    jobTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);


    checkBoxTableColumn.setEditable(true);
    checkBoxTableColumn.setCellValueFactory(
            new PropertyValueFactory<Job, Boolean>("isContextSelected")
    );

    checkBoxTableColumn.setCellFactory(
            new Callback<TableColumn<Job, Boolean>, TableCell<Job, Boolean>>() {
                @Override
                public TableCell<Job, Boolean> call(TableColumn<Job, Boolean> param) {
                    return new CheckBoxTableCell<Job, Boolean>(){
                        {
                            setAlignment(Pos.CENTER);
                        }

                        @Override
                        public void updateItem(Boolean item, boolean empty){
                            if(!empty){
                                TableRow row = getTableRow();

                                if(row != null){
                                    Integer rowNumber = row.getIndex();
                                    TableView.TableViewSelectionModel sm = getTableView().getSelectionModel();

                                    if(item){
                                        sm.select(rowNumber);

                                    }
                                    else{
                                        sm.clearSelection(rowNumber);

                                    }
                                }
                            }
                            super.updateItem(item, empty);
                        }
                    };
                }
            }
    );



    jobNameColumn.setCellValueFactory(
            cellData -> cellData.getValue().nameProperty()
    );

    noOfArticlesColumn.setCellValueFactory(
            cellData -> {
                SimpleIntegerProperty sip = new SimpleIntegerProperty(cellData.getValue().numberOfArticlesProperty().getValue());
                ObservableValue<Integer> ov = sip.asObject();
                return ov;
            }

    );

    alreadyEngagedColumn.setCellValueFactory(
        cellData -> {
            Boolean engaged = false;
            for(Job job: articleEngagementList){
                if(job.getNumberID().equals(cellData.getValue().getNumberID())){
                    engaged = true;
                }
            }

            if(engaged){
                SimpleStringProperty sbp = new SimpleStringProperty("Yes");
                ObservableValue<String> ov = sbp;
                return ov;
            }
            else {
                SimpleStringProperty sbp = new SimpleStringProperty("No");
                ObservableValue<String> ov = sbp;
                return ov;
            }
        }
    );

    jobTableView.getSelectionModel().getSelectedItems().addListener(
            new ListChangeListener<Job>() {
                @Override
                public void onChanged(Change<? extends Job> c) {
                    noOfJobsLabel.setText(String.valueOf(c.getList().size()));
                }
            }
    );






}

public void filterMasterList(){
    for(Job job : masterJobList){
        if(!job.getIsCompleted()){
            currentJobList.add(job);
        }
    }

    for(Job currentJob : currentJobList){
        currentJob.setIsContextSelected(false);
    }
}


@FXML
public void handleOkClicked(){
    if(!Validator.articleJobAssignment(this)){

        for(Job job : jobTableView.getSelectionModel().getSelectedItems()){
            selectedJobList.add(job);
        }
        okClicked = true;
        jobAssignStage.close();
    }
    else {
        errorLabel.setText("Select at least one job");
        errorLabel.setVisible(true);
    }
}

@FXML
public void handleCancelClicked(){
    jobAssignStage.close();
}

public void setArticle(Article article) {
    this.article = article;
    articleNameLabel.setText(article.getName());

}

public void setJobAssignStage(Stage jobAssignStage) {
    this.jobAssignStage = jobAssignStage;
}

public void setOkClicked(boolean okClicked) {
    this.okClicked = okClicked;
}

public void setMainApp(MainApp mainApp) {
    this.mainApp = mainApp;
    setMasterJobList(mainApp.getJobObservableList());
    filterMasterList();
    jobTableView.setItems(currentJobList);

    if(article != null){
        articleEngagementList = PopulateView.articleCurrentEngagementList(articleEngagementList, article.getId(), mainApp.getClientObservableList());
    }
}

public Label getArticleNameLabel() {
    return articleNameLabel;
}

public Label getNoOfJobsLabel() {
    return noOfJobsLabel;
}

public Button getOkButton() {
    return okButton;
}

public Button getCancelButton() {
    return cancelButton;
}

public TableView<Job> getJobTableView() {
    return jobTableView;
}

public TableColumn<Job, String> getJobNameColumn() {
    return jobNameColumn;
}

public TableColumn<Job, String> getClientNameColumn() {
    return clientNameColumn;
}

public TableColumn<Job, Integer> getNoOfArticlesColumn() {
    return noOfArticlesColumn;
}

public ObservableList<Job> getMasterJobList() {
    return masterJobList;
}

public void setMasterJobList(ObservableList<Job> masterJobList) {
    this.masterJobList = masterJobList;
}

public boolean isOkClicked() {
    return okClicked;
}

public ArrayList<Job> getSelectedJobList() {
    return selectedJobList;
}
}

作业类(忽略构造函数):

package BillControl.model;


import BillControl.Controller.PopulateItems;
import BillControl.GeneralUtils.DateUtil;
import javafx.beans.property.*;
import javafx.collections.ObservableList;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;


public class Job {
    private  String numberID;
    private  StringProperty name;
    private  ObjectProperty<Client> client;
    private  StringProperty clientName;
    private  ObjectProperty<Date> startPeriod;
    private  ObjectProperty<Date> endPeriod;
    private  ObjectProperty<Date> startDate;
    private  ObjectProperty<Date> targetDate;
    private  BooleanProperty isDelayed;
    private  LongProperty remainingDays;
    private  LongProperty delayedDays;
    private  BooleanProperty isCompleted;
    private  ObjectProperty<Date> completionDate;
    private  LongProperty daysToComplete;
    private  StringProperty partner;
    private  IntegerProperty numberOfArticles;
    private  BooleanProperty isContextSelected;

private String clientID;

public Job(Client client){


    this.numberID = null;

        this.client = new SimpleObjectProperty<Client>(client);
        this.clientName = new SimpleStringProperty(client.getName());
        this.name = new SimpleStringProperty("");
        this.partner = new SimpleStringProperty("");
        this.startDate = new SimpleObjectProperty<Date>();
        this.targetDate = new SimpleObjectProperty<Date>();
        this.completionDate = new SimpleObjectProperty<Date>();
        this.isCompleted = new SimpleBooleanProperty(false);
        this.startPeriod = new SimpleObjectProperty<Date>();
        this.endPeriod = new SimpleObjectProperty<Date>();
        this.fillOthers(false);
    //        todo check fill others logic


    }

    public Job(ObservableList clientList, String numberID){
        this.numberID = numberID;
//        this.numberID = null;
        this.name = new SimpleStringProperty("");
        this.partner = new SimpleStringProperty("");
        this.startDate = new SimpleObjectProperty<Date>();
        this.targetDate = new SimpleObjectProperty<Date>();
        this.completionDate = new SimpleObjectProperty<Date>();
        this.isCompleted = new SimpleBooleanProperty(false);
        this.startPeriod = new SimpleObjectProperty<Date>();
        this.endPeriod = new SimpleObjectProperty<Date>();
        this.client = new SimpleObjectProperty<Client>();
        this.clientName = new SimpleStringProperty();
        this.numberOfArticles = new SimpleIntegerProperty();
        this.isContextSelected = new SimpleBooleanProperty(false);
        PopulateItems.populateJob(this);
        Client selectedClient = null;
    for(Object clientObject :  clientList){
        Client queriedClient = (Client) clientObject;
        String name =  queriedClient.getName();
        String queriedName = PopulateItems.clientID2NameHelper(this.getClientID());
        if(name.equals(queriedName)){
            selectedClient = (Client) clientObject;
            break;
        }
    }
    this.setClient(selectedClient);
    this.setClientName(this.getClient().getName());

    this.fillOthers(true);
}

public Job(){
    this.numberID = null;
    this.client = new SimpleObjectProperty<Client>();
    this.clientName = new SimpleStringProperty("");
    this.name = new SimpleStringProperty("");
    this.partner = new SimpleStringProperty("");
    this.startDate = new SimpleObjectProperty<Date>();
    this.targetDate = new SimpleObjectProperty<Date>();
    this.completionDate = new SimpleObjectProperty<Date>();
    this.isCompleted = new SimpleBooleanProperty(false);
    this.startPeriod = new SimpleObjectProperty<Date>();
    this.endPeriod = new SimpleObjectProperty<Date>();
    this.fillOthers(false);
}

public void fillOthers(Boolean filledJob){
    if(filledJob){

        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        try {
            Date startDate = this.getStartDate();
            Date completionDate = this.getCompletionDate();
            Date currentDate = DateUtil.getCurrentDate();
            Date targetDate = this.getTargetDate();



            if (this.getIsCompleted()){
//                completion days
                    this.daysToComplete = new SimpleLongProperty();
                    long duration = completionDate.getTime() - startDate.getTime();
                    long diffInDays = TimeUnit.MILLISECONDS.toDays(duration);
                    this.setDaysToComplete(diffInDays);

            }
            else{
                this.remainingDays = new SimpleLongProperty();
                this.isDelayed = new SimpleBooleanProperty();
                if (targetDate.after(currentDate) && !this.getIsCompleted()){

                    //            remaining days
                    long duration = targetDate.getTime() - currentDate.getTime();
                    long diffInDays = TimeUnit.MILLISECONDS.toDays(duration);
                    this.setRemainingDays(diffInDays);
                    this.setIsDelayed(false);
                }
                else if (targetDate.before(currentDate) && !this.getIsCompleted()) {
//                delayed days
                        this.delayedDays = new SimpleLongProperty();
                        this.setIsDelayed(true);
                        long duration = currentDate.getTime() - targetDate.getTime();
                        long diffInDays = TimeUnit.MILLISECONDS.toDays(duration);
                        this.setRemainingDays(0);
                        this.setDelayedDays(diffInDays);
                    }
                }

            }

        catch (Exception e){
            e.printStackTrace();
        }
    }
    else {
//TODO client creation form job
    }

}

public String getName() {
    return name.get();
}

public StringProperty nameProperty() {
    return name;
}

public void setName(String name) {
    this.name.set(name);
}

public Client getClient() {
    return client.get();
}

public ObjectProperty<Client> clientProperty() {
    return client;
}

public void setClient(Client client) {
    this.client.set(client);
}

public Date getStartDate() {
    return startDate.get();
}

public ObjectProperty<Date> startDateProperty() {
    return startDate;
}

public void setStartDate(Date startDate) {
    this.startDate.set(startDate);
}

public Date getTargetDate() {
    return targetDate.get();
}

public ObjectProperty<Date> targetDateProperty() {
    return targetDate;
}

public void setTargetDate(Date targetDate) {
    this.targetDate.set(targetDate);
}

public boolean getIsDelayed() {
    return isDelayed.get();
}

public BooleanProperty isDelayedProperty() {
    return isDelayed;
}

public void setIsDelayed(boolean isDelayed) {
    this.isDelayed.set(isDelayed);
}

public long getRemainingDays() {
    return remainingDays.get();
}

public LongProperty remainingDaysProperty() {
    return remainingDays;
}

public void setRemainingDays(long remainingDays) {
    this.remainingDays.set(remainingDays);
}

public long getDelayedDays() {
    return delayedDays.get();
}

public LongProperty delayedDaysProperty() {
    return delayedDays;
}

public void setDelayedDays(long delayedDays) {
    this.delayedDays.set(delayedDays);
}

public boolean getIsCompleted() {
    return isCompleted.get();
}

public BooleanProperty isCompletedProperty() {
    return isCompleted;
}

public void setIsCompleted(boolean isCompleted) {
    this.isCompleted.set(isCompleted);
}

public Date getCompletionDate() {
    return completionDate.get();
}

public ObjectProperty<Date> completionDateProperty() {
    return completionDate;
}

public void setCompletionDate(Date completionDate) {
    this.completionDate.set(completionDate);
}

public long getDaysToComplete() {
    return daysToComplete.get();
}

public LongProperty daysToCompleteProperty() {
    return daysToComplete;
}

public void setDaysToComplete(long daysToComplete) {
    this.daysToComplete.set(daysToComplete);
}

public String getPartner() {
    return partner.get();
}

public StringProperty partnerProperty() {
    return partner;
}

public void setPartner(String partner) {
    this.partner.set(partner);
}

public Integer getNumberOfArticles() {
    return numberOfArticles.get();
}

public IntegerProperty numberOfArticlesProperty() {
    return numberOfArticles;
}

public void setNumberOfArticles(int numberOfArticles) {
    this.numberOfArticles.set(numberOfArticles);
}

public String getNumberID() {
    return numberID;
}

public String getClientName() {
    return clientName.get();
}

public StringProperty clientNameProperty() {
    return clientName;
}

public void setClientName(String clientName) {
    this.clientName.set(clientName);
}

public Date getStartPeriod() {
    return startPeriod.get();
}

public ObjectProperty<Date> startPeriodProperty() {
    return startPeriod;
}

public void setStartPeriod(Date startPeriod) {
    this.startPeriod.set(startPeriod);
}

public Date getEndPeriod() {
    return endPeriod.get();
}

public ObjectProperty<Date> endPeriodProperty() {
    return endPeriod;
}

public void setEndPeriod(Date endPeriod) {
    this.endPeriod.set(endPeriod);
}

public String getClientID() {
    return clientID;
}

public void setClientID(String clientID) {
    this.clientID = clientID;
}

public boolean getIsContextSelected() {
    return isContextSelected.get();
}

public BooleanProperty isContextSelectedProperty() {
    return isContextSelected;
}

public void setIsContextSelected(boolean isContextSelected) {
    this.isContextSelected.set(isContextSelected);
}
}

好的,这是一种方法。您的支持模型中需要一个 BooleanProperty 来保存复选框的值,以便当行滚动到视图之外然后再次返回时,表将“记住”是否应选择该行复选框。

TableColumn<Job,Boolean>  checkCol = new TableColumn<>("Check");
checkCol.setCellValueFactory( new PropertyValueFactory<Job,Boolean>( "checkBoxValue" ) );
checkCol.setCellFactory( new Callback<TableColumn<Job,Boolean>, TableCell<Job,Boolean>>()
{
    @Override
    public TableCell<Job,Boolean> call( TableColumn<Job,Boolean> param )
    {
        return new CheckBoxTableCell<Job,Boolean>()
        {
            {
                setAlignment( Pos.CENTER );
            }
            @Override
            public void updateItem( Boolean item, boolean empty )
            {
                if ( ! empty )
                {
                    TableRow  row = getTableRow();

                    if ( row != null )
                    {
                        int rowNo = row.getIndex();
                        TableViewSelectionModel  sm = getTableView().getSelectionModel();

                        if ( item )  sm.select( rowNo );
                        else  sm.clearSelection( rowNo );
                    }
                }

                super.updateItem( item, empty );
            }
        };
    }
} );
checkCol.setEditable( true );
checkCol.setMaxWidth( 50 );
checkCol.setMinWidth( 50 );
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

带复选框的 Javafx 8 Tableview 选择 的相关文章

  • 如何仅通过鼠标使用 javafx 在表格视图中选择多个单元格?

    我有一个在 javafx 中带有表格视图的应用程序 我想仅通过鼠标选择多个单元格 类似于 Excel 中存在的选择 我尝试过 但我不能做某事 这个问题的正确答案在这里https community oracle com thread 262
  • 设置默认 JavaFX 对话框的样式

    我正在寻找一种方法来设置默认 JavaFX 对话框的样式 javafx scene control Dialog 我尝试获取 DialogPane 并添加样式表 但它只覆盖了对话框的一小部分 我更喜欢仅使用外部 css 文件设置样式 而不在
  • 有没有办法在坐标平面上动态绘制点之间的线?

    我正在完成一个项目 在该项目中我实现了一个暴力算法来解决凸包问题 我还需要为该算法创建视觉效果 我试图在 x 轴和 y 轴上创建一个范围从 100 100 的坐标平面 绘制完整集中的所有点 并在点之间动态绘制线条以创建凸包 例如 假设我有
  • RichTextFx CodeArea 中的文本背景颜色

    我正在使用 RichTextFx CodeArea 来突出显示我的代码 我想更改某些关键字的文本背景颜色并使用下面的 css parameter rtfx background color yellow But it s changes b
  • 添加样式后如何重置回默认CSS?

    基本上 我通过添加如下样式类来更改 javafx 中文本字段的 css textfield getStyleClass add textfieldstyle 但后来我希望能够将其恢复到原来的样子 但由于本例中的原始外观是 JavaFX 的默
  • JavaFX 8 DatePicker 风格

    如何更改JavaFX 8中DatePicker中日历的样式 我查看了 modena 文件中的所有默认样式 但没有找到 DatePicker 的类 有人知道该怎么做吗 例如 将标题颜色更改为蓝色 默认样式如下 您可以找到以下的 cssDate
  • JavaFX 使用动画最小化和最大化未装饰的舞台

    我在这个问题中使用已接受的答案 JavaFX 最小化未修饰的阶段 https stackoverflow com questions 26972683 javafx minimizing undecorated stage正确最小化我的应用
  • JavaFX ProgressBar:如何添加动画?

    我创建了一个进度条并更改了进度条颜色 是否可以像 bootstrap 动画进度条一样向进度条添加动画 这是示例 链接在这里 http getbootstrap com components progress animated 实际上 我找到
  • 尝试使 Tableview 可点击时发生 JavaFX 错误

    我正在尝试使表格视图可单击 它将返回单击的单元格中的文本 尝试在 Netbeans 中编译时收到两个错误 所有代码均取自 示例12 11 单元格编辑的替代解决方案 官方表格视图教程 http docs oracle com javafx 2
  • 如何使用 Java 11 和 JavaFX 11 运行 ControlsFX 示例应用程序

    ControlFX 网站 http fxexperience com controlsfx says 如果您想使用 ControlsFX 示例应用程序 只需 下载 ControlsFX 版本并在上运行以下命令 命令提示符 请务必将 替换为实
  • Swift 4.2 当键盘显示时使 tableView 的底部向上移动

    尽管我已经进行了搜索 但我对如何最好地解决这个问题感到困惑 我有一个 tableView 其中底部单元格是列表的输入 就像苹果提醒的工作方式一样 当列表中的项目太多时 键盘会覆盖列表 我看不到正在输入的内容 我认为我需要更改表视图的物理大小
  • 检测 TableView JavaFX 行上的双击

    我需要检测 a 的一行上的双击TableView 如何监听该行任何部分的双击并获取该行的所有数据并将其打印到控制台 TableView
  • JavaFX 2:TableView:删除标题+空时显示网格

    我有两个关于 Javafx 2 中的 TableView 的问题 1 是否可以隐藏表格中的标题 2 当表为空时 它只显示一个白色窗格 上面写着 表中没有内容 是否可以更改此设置以显示默认网格 即使表格为空 如果可能的话 我想要一个带有 CS
  • IntelliJ 不会从 Maven 依赖项加载 javafx 包 (JavaFX 17)

    我正在尝试获取一个 Maven JavaFX 项目 该项目是从javafx 原型 fxml原型且未经编辑 可在最新版本的 IntelliJ 中运行 需要明确的是 该项目是该原型的直接复制 我只是想让一个例子起作用 可以说我是 Maven 的
  • 从剪贴板获取图像 Awt 与 FX

    最近 我们的 Java FX 应用程序无法再从剪贴板读取图像 例如 用户在 Microsofts Paint 中选择图像的一部分并按复制 我不是在谈论复制的图像文件 它们工作得很好 我很确定它过去已经有效 但我仍然需要验证这一点 尽管如此
  • iOS 11 浮动 TableView 标题

    有一个应用程序包含多个部分 展开 时每个部分有几行 折叠 时没有 每个部分都有一个部分标题 使用以下子类重用它们UITableViewHeaderFooterView等等 到目前为止一切顺利 然后在 iOS 11 中 我使用了可视化调试器
  • 将 JavaFX FXML 对象分组在一起

    非常具有描述性和信息性的答案将从我这里获得价值 50 声望的赏金 我正在 JavaFX 中开发一个应用程序 对于视图 我使用 FXML
  • JavaFX 中的 fx:id 和 id: 有什么区别?

    也许是一个真正的新手的问题 我开始通过阅读以下教程在 FMXL 应用程序中使用场景生成器学习 JavaFX http docs oracle com javase 8 javafx get started tutorial fxml tut
  • 删除 JFX 中选项卡后面的灰色背景

    So is there any way to remove the gray area behind the tab s 我尝试过用 CSS 来做到这一点 但没有找到方法 要设置 tabpane 标题的背景颜色 请在 CSS 文件中写入 t
  • 标签文字位置

    我有一个带有图像和文本的标签 final Label label new Label labelText label setTextAlignment TextAlignment CENTER ImageView livePerformIc

随机推荐