/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package bugs; import java.awt.BorderLayout; import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.SwingUtilities; import javafx.scene.control.Button; import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.application.Platform; import javafx.embed.swing.JFXPanel; import javafx.event.EventHandler; import javafx.scene.control.CheckBox; import javafx.scene.control.TextField; import javafx.scene.layout.HBox; public class FXCanvasAppSwing_RT33390 { public static String MAIN_CONTAINER_ID = "main.container.id"; public static String HEAVY_POPUP_CONTAINER_ID = "heavy.container.id"; public static String MENU_POPUP_CONTAINER_ID = "menu.container.id"; public static int SCENE_WIDTH = 200; public static int SCENE_HEIGHT = 200; public FXCanvasAppSwing_RT33390() { } protected void reset() { } //Creates simple JavaFXScene static Scene createScene(String id) { final VBox pane = new VBox(); pane.setMinSize(SCENE_WIDTH, SCENE_HEIGHT); pane.setMaxSize(SCENE_WIDTH, SCENE_HEIGHT); pane.setPrefSize(SCENE_WIDTH, SCENE_HEIGHT); pane.setId(id); Scene scene = new Scene(pane, SCENE_WIDTH, SCENE_HEIGHT); final TextField text_input = new TextField("TextInput"); pane.getChildren().add(text_input); HBox button_box = new HBox(5); pane.getChildren().add(button_box); final CheckBox check = new CheckBox("Button pressed"); final Button button = new Button("Button"); button.setOnAction(new EventHandler() { @Override public void handle(javafx.event.ActionEvent t) { check.setSelected(true); } }); button_box.getChildren().add(button); button_box.getChildren().add(check); return scene; } public static void initAndShowGUI() { JFrame frame = new JFrame("Swing application"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create JavaFX panel. final JFXPanel fxPanel = new JFXPanel(); fxPanel.setPreferredSize(new Dimension(550, 400)); frame.getContentPane().add(fxPanel, BorderLayout.CENTER); Platform.runLater(new Runnable () { public void run () { VBox group = new VBox(); final Scene scene = createScene("12"); SwingUtilities.invokeLater(new Runnable() { public void run() { fxPanel.setScene(scene); } }); } }); // Show frame. frame.pack(); frame.setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { initAndShowGUI(); } }); } }