Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8350328

In Eclipse 4 RCP Product can't run javafx.embed.swt.FXCanvas

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz 2.90 GHz
      RAM=16.0 GB
      x64 System

      A DESCRIPTION OF THE PROBLEM :
      my code in a MPart:
      @PostConstruct
      public void createComposite(Composite parent) {
      parent.setLayout(new GridLayout(1, false));

      /* Create the SWT button */
      final org.eclipse.swt.widgets.Button swtButton = new org.eclipse.swt.widgets.Button(parent, SWT.PUSH);
      swtButton.setText("SWT Button");

      /* Create an FXCanvas */
      final FXCanvas fxCanvas = new FXCanvas(parent, 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);
      }
      };
      /* Create a JavaFX Group node */
      Group group = new Group();
      /* Create a JavaFX button */
      final Button jfxButton = new Button("JFX Button");
      /* Assign the CSS ID ipad-dark-grey */
      jfxButton.setId("ipad-dark-grey");
      /* Add the button as a child of the Group node */
      group.getChildren().add(jfxButton);
      /* Create the Scene instance and set the group node as root */
      Scene scene = new Scene(group, Color.rgb(parent.getBackground().getRed(), parent.getBackground().getGreen(),
      parent.getBackground().getBlue()));
      /* Attach an external stylesheet */
      scene.getStylesheets().add("twobuttons/Buttons.css");
      fxCanvas.setScene(scene);

      /* Add Listeners */
      swtButton.addListener(SWT.Selection, new Listener() {

      @Override
      public void handleEvent(Event event) {
      jfxButton.setText("JFX Button: Hello from SWT");
      parent.layout();
      }
      });
      jfxButton.setOnAction(new EventHandler<ActionEvent>() {

      @Override
      public void handle(ActionEvent event) {
      swtButton.setText("SWT Button: Hello from JFX");
      parent.layout();
      }
      });

      }


      Error:
      !SESSION 2025-02-08 01:37:16.260 -----------------------------------------------
      eclipse.buildId=unknown
      java.version=21.0.5
      java.vendor=Eclipse Adoptium
      BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=zh_CN
      Framework arguments: -product QQMusicFake.product -clearPersistedState
      Command-line arguments: -product QQMusicFake.product -data E:\eclipse\workspace/../runtime-QQMusicFake.product -dev file:E:/eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/QQMusicFake.product/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog -clearPersistedState

      !ENTRY org.eclipse.e4.ui.workbench 1 0 2025-02-08 01:37:17.587
      !MESSAGE e4 life cycle
      2月 08, 2025 1:37:18 上午 com.sun.javafx.application.PlatformImpl startup
      警告: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @6601cc93'
      Graphics Device initialization failed for : d3d, sw
      Error initializing QuantumRenderer: no suitable pipeline found
      java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
      at com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:283)
      at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:253)
      at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:263)
      at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:290)
      at javafx.application.Platform.startup(Platform.java:116)
      at javafx.embed.swt.FXCanvas.lambda$initFx$4(FXCanvas.java:355)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:461)
      at javafx.embed.swt.FXCanvas.initFx(FXCanvas.java:354)
      at javafx.embed.swt.FXCanvas.<clinit>(FXCanvas.java:271)
      at qqmusicfake.parts.SamplePart.createComposite(SamplePart.java:65)
      at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
      at java.base/java.lang.reflect.Method.invoke(Method.java:580)
      at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
      at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:977)
      at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:139)
      at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:386)
      at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:312)
      at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:203)
      at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:90)

      REGRESSION : Last worked in version 21

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1、just use eclipse pde tool to create a sample rcp project in eclipse version 4.32
      2、add Javafx libs in MANIFEST.MF graphic editor:
      (a) download javafx sdk,copy the four jar:
      javafx-swt.jar,
      javafx.base.jar,
      javafx.graphics.jar,
      javafx.controls.jar
      (b) create a folder in the rcp project root,called lib or other.
      (c) double click to open MANIFEST.MF Graphic Editor:
      (d) Build->Extra ClassPath Entries->Add the libs above(choose the jars in the "lib" folder one by one,don't choose the folder itself),
      (e) Then Switch to Runtime:
      Runtime->ClassPath->Add all the libs above(not New)
      (f) copy the code to the SamplePart.java (del the createComposite method,and paste from clipboard)
      (g) right click the ".product" file.Run as->Eclipse Application.
      (h) and you will see the error messages above.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The Error Will repeat again.
      ACTUAL -
      error occur again.

            adev Anupam Dev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: