JavaFX ComboBox 在 Windows 10 上没有响应 [英] JavaFX ComboBox not responding on Windows 10

查看:28
本文介绍了JavaFX ComboBox 在 Windows 10 上没有响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级到了 Windows 10,而在 Windows 8.1 中工作的 JavaFX 代码似乎在 10 中冻结了.我已经将问题追溯到在对话框中打开 ComboBox.这似乎会冻结任何 JavaFX 程序.有没有其他人有同样的问题?(Windows 10 计算机仍然很少,因此最好确认错误确实是 JavaFX 问题)

I recently upgraded to Windows 10 and JavaFX code which worked in Windows 8.1 appears to freeze up in 10. I've tracked the issue down to opening a ComboBox within a dialog. This appears to freeze any JavaFX program. Does anyone else have the same issue? (Windows 10 computers are still few and far between so would be good to confirm bug is indeed JavaFX issue)

我在下面附上了示例代码.主阶段中的 ComboBox 很好,但是当我打开一个对话框并尝试在那里使用 ComboBox 时,整个事情都冻结了.我在 Eclipse 4.4.0 中使用 Java 8u51

I have attached example code below. The ComboBox in the main stage is fine but when I open a dialog and try and use the ComboBox there, the whole thing freezes. I'm using Java 8u51 in Eclipse 4.4.0

package javafxExamples;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceDialog;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class ComboErrorTest extends Application {

String[] list={"Jamie", "Arthur", "Gordon"};

private Stage stage;

public static void main(String[] args) {
    launch(args);
}


@Override
public void start(Stage stage) throws Exception {
    //create box in main stage.
    ComboBox<String> comboBox=new ComboBox<String>(); 
    for (int i=0; i<list.length; i++){
        comboBox.getItems().add(list[i]);
    }
    comboBox.getSelectionModel().select(list[0]);

    BorderPane pane = new BorderPane(comboBox);
    pane.setPrefSize(400, 250);

    //dialog bit
    List<String> choices = new ArrayList<>();
    choices.add("a");
    choices.add("b");
    choices.add("c");

    ChoiceDialog<String> dialog = new ChoiceDialog<>("b", choices);
    dialog.setTitle("Choice Dialog");
    dialog.setHeaderText("Look, a Choice Dialog");
    dialog.setContentText("Choose your letter:");


    Button dialogButton=new Button("Open Dialog...");
    dialogButton.setOnAction((action)->{
        // Traditional way to get the response value.
        Optional<String> result = dialog.showAndWait();
        if (result.isPresent()){
            System.out.println("Your choice: " + result.get());
        }
    });

    pane.setBottom(dialogButton);

    Scene scene = new Scene(pane);

    stage.setTitle("ComboError Demo");
    stage.setScene(scene);
    stage.show();

}

}

推荐答案

根据错误报告,临时解决方法是设置以下系统属性:

According to the bug report, a temporary workaround is setting the following system property:

java -Dglass.accessible.force=false ... 

或者,在应用程序的代码中:

or, in an application's code:

System.setProperty("glass.accessible.force", "false");

或者,或者,运行 Windows 讲述人屏幕阅读器(启用辅助功能)".

Or, alternately, "Run the Windows Narrator screen reader (with accessibility left enabled)".

该错误似乎已在 JDK 8u40 中引入,并影响安装并启用了触摸屏的 Windows 10 系统.

The bug appears to have been introduced in JDK 8u40, and affects Windows 10 systems with a touchscreen installed and enabled.

一些快速测试似乎表明它为我解决了问题.

Some quick testing seems to indicate that it solved the problem for me.

这篇关于JavaFX ComboBox 在 Windows 10 上没有响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆