JavaFX - SWT interop: application freezes

I am creating an RCP application based on Eclipse 3.5. Thanks to two articles ( 1 , 2 ) that I found on oracle.com, I was able to implement a working RCP view that displays a pie chart.

Unfortunately, if I close the view and open it again, then the applications freeze and never return.

I am using JavaFX 2.2.7 under JDK 1.6.0.31 on Windows 7 X64.

Here is the code. The view is a standard subclass of org.eclipse.ui.part.ViewPart.

Composite panel = new Composite(parent, SWT.NONE); RowLayout layout = new RowLayout(); panel.setLayout(layout); FXCanvas fxCanvas = new FXCanvas(panel, SWT.NONE) { @Override public Point computeSize(int wHint, int hHint, boolean changed) { getScene().getWindow().sizeToScene(); int width = (int) getScene().getWidth(); int height = (int) getScene().getHeight(); return new Point(width, height); } }; Scene scene = new Scene(new Group()); RGB rgb = panel.getBackground().getRGB(); Color color = Color.rgb(rgb.red, rgb.green, rgb.blue); scene.setFill(color); ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(); pieChartData.add(new PieChart.Data("label1", 20)); pieChartData.add(new PieChart.Data("label2", 20)); pieChartData.add(new PieChart.Data("label3", 20)); pieChartData.add(new PieChart.Data("label4", 20)); pieChartData.add(new PieChart.Data("label5", 20)); Chart chart = new PieChart(pieChartData); chart.setLegendSide(Side.RIGHT); ((Group) scene.getRoot()).getChildren().add(chart); fxCanvas.setScene(scene); 

Can anyone help?

+4
source share
1 answer

The problem is resolved. This was caused by some thread naming changes elsewhere in the application. There are certain things that cannot be done. One of them is the overuse of stream names. :)

The utility class relied on thread names to run code in the user interface thread, and because JavaFX changes the name of the current thread, the utility class will no longer work.

+2
source

Source: https://habr.com/ru/post/1469528/


All Articles