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

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

问题描述

我最近升级到Windows 10,在Windows 8.1中工作的JavaFX代码似乎在10中冻结。我已经跟踪了在对话框中打开ComboBox的问题。这似乎冻结了任何JavaFX程序。还有其他人有同样的问题吗? (Windows 10计算机仍然很少,所以很好地确认bug确实是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天全站免登陆