【问题标题】:JavaFX Rectangle stops ComboBox displaying drop-downJavaFX Rectangle 停止 ComboBox 显示下拉菜单
【发布时间】:2018-05-18 03:51:45
【问题描述】:

我需要显示一个带有 InnerShadow 效果的矩形作为我的 JavaFX 节点的背景。每个节点都需要调整大小。我正在使用一个抽象基类来实现这一点,该基类具有一个带有 InnerShadow 的矩形作为其子级之一的区域,以及由此类的具体实现提供的一个区域作为其另一个子级。

当我将一个或多个 ComboBoxes 添加到子区域时,会出现此问题。单击 ComboBox 没有任何效果,即它们不会显示其下拉项目列表。

我已尝试将 Rectangle 缩小(即 10x10 像素),使其不会与 ComboBoxes 重叠。这没什么区别。

private void createNodeWithBackground() {
    pane = new Region() {
        @Override
        public void resize(double width, double height) {
            super.resize(width, height);

            backing = new Rectangle(width, height);
            InnerShadow shadeEffect = new InnerShadow();
            shadeEffect.setWidth(w/2);
            shadeEffect.setHeight(h/2);
            shadeEffect.setInput(new ColorAdjust(-0.1, 0.2, -0.1, 0.1));
            backing.setEffect(shadeEffect);

            getChildren().clear();
            getChildren().addAll(backing, getBodyNode());
        }
    };
    getChildren().add(pane);
}

/**
 * The concrete class provides a node to be displayed on top of the
 * Rectangle with the InnerShadow.
 * This might be a VBox containing a ComboBox and other nodes.
 */
protected abstract Region getBodyNode();

从场景中移除矩形会导致组合框按预期显示下拉列表。

【问题讨论】:

标签: javafx combobox resize


【解决方案1】:

使用 javafx.scene.control.ChoiceBox 代替 javafx.scene.control.ComboBox 解决了这个问题,虽然我不知道为什么。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-07
    • 2016-11-11
    • 2018-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多