问题描述
我最近升级到Windows 10和JavaFX代码在Windows 8.1中工作似乎冻结在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 Narrator屏幕阅读器
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 Windows 10 ComboBox错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!