相关疑难解决方法(0)

JavaFX tableview颜色

我需要创建具有多色行的JavaFx TableView(color1用于低优先级,color2用于中等优先级等).我创建了CellFactory

public class TaskCellFactory implements Callback<TableColumn, TableCell> {

@Override
public TableCell call(TableColumn p) {

   TableCell cell = new TableCell<Task, Object>() {
        @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 priority = currentTask.getPriority();
                clearPriorityStyle();
                if(!isHover() && !isSelected() && !isFocused()){
                    setPriorityStyle(priority);
                }
            }
        }

        @Override
        public void updateSelected(boolean upd){
            super.updateSelected(upd);
            System.out.println("is update");
        }

        private void …
Run Code Online (Sandbox Code Playgroud)

java javafx tableview

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

标签 统计

java ×1

javafx ×1

tableview ×1