小编Olg*_*aya的帖子

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万
查看次数

如果内容发生更改,则自动调整舞台大小

我使用SceneBuilder和相应的场景和舞台创建了AnchorPane.AnchorPane包含VBox.所有尺寸的AnchorPane都是USE_COMPUTED_SIZE.VBox的高度改为programmicaly,但场景和舞台的大小不会改变.

如何让它们自动调整为内容大小?

java javafx-2

4
推荐指数
1
解决办法
4593
查看次数

标签 统计

java ×2

javafx ×1

javafx-2 ×1

tableview ×1