java - AWT Panel not getting rendered in JFX -


i want add java.awt.panel javafx8 application. unfortunately seems panel doesn't rendered when attached swingnode.

i have simple testapplication:

import java.awt.dimension; import java.util.concurrent.callable; import java.util.concurrent.executionexception; import java.util.concurrent.futuretask; import java.util.logging.level; import java.util.logging.logger; import javafx.application.application; import javafx.embed.swing.swingnode; import javafx.scene.group; import javafx.scene.scene; import javafx.stage.stage; import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.swingutilities;  public class awtinjfx extends application {      @override     public void start(stage stage) {          final awtinitializertask awtinitializertask = new awtinitializertask(() -> {                 awtpanel panel = new awtpanel();                 return panel;         });          swingnode swingnode = new swingnode();          swingutilities.invokelater(awtinitializertask);         try {             swingnode.setcontent(awtinitializertask.get());         } catch (interruptedexception | executionexception ex) {             logger.getlogger(awtinjfx.class.getname()).log(level.severe, null, ex);         }          stage.setscene(new scene(new group(swingnode), 600, 600));         stage.setresizable(false);         stage.show();                 swingutilities.invokelater(() -> {             jframe frame = new jframe();             frame.setsize(new dimension(600, 400));             frame.add(new awtpanel());             frame.setvisible(true);         });     }      /**      * @param args command line arguments      */     public static void main(string[] args) {         launch(args);     }      private class awtinitializertask extends futuretask<jpanel> {         public awtinitializertask(callable<jpanel> callable) {             super(callable);         }     }  } 

my jpanel containing java.awt.panel

import java.awt.color; import java.awt.dimension; import java.awt.panel; import javax.swing.jpanel;  public class awtpanel extends jpanel{     public awtpanel()     {         dimension d = new dimension(600, 400);         setpreferredsize(d);         panel p = new panel();         p.setsize(d);         p.setpreferredsize(d);         p.setbackground(color.red);         this.add(p);         this.setbackground(color.green);     } } 

other awt components doesn't show either when add awtpanel swingnode.

can explain me why isn't working?

i need awt panel hwnd used in additonal c++ libraries.

from swingnode javadocs:

the hierarchy of components contained in jcomponent instance should not contain heavyweight components, otherwise swingnode may fail paint it.

as far know, there no way embed heavyweight component, such awt component, in javafx.

depending on requirements, consider reversing things around, have swing/awt frame main window, , embed javafx part of application in jfxpanel.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -