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)
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();
}
}