Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      generic

      Description

      A DESCRIPTION OF THE PROBLEM :
      If I Open a new Stage with a SwingNode and close it. The SwingNode stays in the Heap but it isn't reachable anymore.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Open a new Window with the Button
      Close the Window with X

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The SwingNode is not reachable anymore and should be disposed
      ACTUAL -
      The SwingNode stays in the heap and is never disposed

      ---------- BEGIN SOURCE ----------
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      import javax.swing.JButton;
      import javax.swing.SwingUtilities;

      import javafx.application.Application;
      import javafx.application.Platform;
      import javafx.embed.swing.SwingNode;
      import javafx.scene.Scene;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      /**
       *
       */
      public class JFXDemo extends Application {

      Stage stage;

      /**
      * @param args
      */
      public static void main( final String[] args ) {
      launch( args );
      }

      @SuppressWarnings("restriction")
      @Override
      public void start( final Stage stage ) {
      final SwingNode swingNode = new SwingNode();

      createSwingContent( swingNode );

      final StackPane pane = new StackPane();
      pane.getChildren().add( swingNode );

      stage.setTitle( "Swing in JavaFX" );
      stage.setScene( new Scene( pane, 250, 150 ) );
      stage.show();
      }

      private void createSwingContent( final SwingNode swingNode ) {
      SwingUtilities.invokeLater( new Runnable() {
      @Override
      public void run() {
      final JButton button = new JButton( "Click" );
      button.addActionListener( new ActionListener() {

      @Override
      public void actionPerformed( final ActionEvent e ) {

      final SwingNode swingNode = new SwingNode();

      createSwingContent( swingNode );

      final StackPane pane = new StackPane();
      pane.getChildren().add( swingNode );
      Platform.runLater( () -> {
      new Runnable() {
      @Override
      public void run() {
      Stage myStage;
      myStage = new Stage();
      myStage.setTitle( "Swing in JavaFX" );
      myStage.setScene( new Scene( pane, 250, 150 ) );
      myStage.show();

      }
      }.run();
      } );

      }
      } );
      swingNode.setContent( button );

      }
      } );
      }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              psadhukhan Prasanta Sadhukhan
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: