Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The scenegraph used in JavaFX is opensource. You can check it here (<a href="https://scenegraph.dev.java.net" rel="nofollow noreferrer">https://scenegraph.dev.java.net</a>). While the site hasn't been updated to reflect the final version shipped with JavaFX 1.x, you can still use the jar that comes with the JavaFX SDK and mix scenegraph and swing nodes inside your swing application. However, you'll have some difficulty because there's no official API for this version of scenegraph.</p> <p>Here's a "hello world" using the scenegraph that comes woth JavaFX 1.0. Remember to include the "Scenario.jar" in your build path.</p> <pre><code>import java.awt.Color; import java.awt.Paint; import java.awt.geom.Point2D; import javax.swing.JFrame; import javax.swing.SwingUtilities; import com.sun.scenario.scenegraph.JSGPanel; import com.sun.scenario.scenegraph.SGGroup; import com.sun.scenario.scenegraph.fx.FXText; public class HelloWorldScenario101 implements Runnable { /** * @param args */ public static void main(String[] args) { SwingUtilities.invokeLater(new HelloWorldScenario101()); } public HelloWorldScenario101() { // } @Override public void run() { this.frame = new JFrame(); this.panel = new JSGPanel(); this.text = new FXText(); this.paint = new Color(255, 0, 0, 255); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("Hello World"); frame.add(this.panel); frame.setContentPane(this.panel); scene = new SGGroup(); this.text.setText("Hello World"); this.text.setFillPaint(this.paint); this.text.setLocation(new Point2D.Float(10, 10)); this.scene.add(this.text); this.panel.setScene(scene); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); } private JFrame frame; private JSGPanel panel; private SGGroup scene; private FXText text; private Paint paint; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload