If your program generates or reads 3D mesh data (triangles) and is able to create a String object containing a well defined X3D document representing these 3D objects then the Java 3D(TM) API and the XModelImporter API might provide a solution for you.
XModelImporter provides Java 3D importers for "Extensible 3D (X3D)" files. In this case the 'com.interactivemesh.j3d.interchange.ext3d.XModelReader' seems to be the appropriate importer, alternatively 'com.interactivemesh.j3d.interchange.ext3d.XModelLoader'.
The XModelReader imports X3D files by accepting different sources like 'java.io.File' and 'java.net.URL' for external data, but also 'java.io.Reader' which should be applicable for internal stored data, too.
Following not tested scenario might work:
- write the X3D document into a StringBuilder object
- create the corresponding String object (StringBuilder.toString)
- create a java.io.StringReader instance with this X3D string
- create a XModelReader instance and import the X3D data by calling XModelReader.read(java.io.Reader reader)
- calling XModelReader.getImport() returns an array of 'javax.media.j3d.Node' which can be rendered with Java 3D
Java 3D https://java3d.java.net/binary-builds.html
XModelReader http://www.java.net/node/706300
I'm not aware of any "currently supported" ready to go VRML or X3D players for Swing or JavaFX. Instead of converting meshes to and back from VRML or X3D you might consider choosing one of the 3D APIs for the Java platform and convert your data directly into the related format.
August