Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8120292

SwingNode is not Resizable

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8
    • 8
    • javafx
    • Win7-64

    Description

      Run the following code. The initial visible color is green but it should be red (the fill color specified on the content). When manually resizing the window, the content appears.

      import java.awt.Color;

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

      import javax.swing.JPanel;
      import javax.swing.SwingUtilities;

      public class SwingNodeResizeContent extends Application {
      private SwingNode swingNode;
      private JPanel jPanel;

      @Override
      public void start(Stage stage) {
      StackPane root = new StackPane();
      root.setStyle("-fx-background-color: #00FF00;");

      swingNode = new SwingNode();
      swingNode.setStyle("-fx-background-color: #0000FF;");
      root.getChildren().add(swingNode);

      Scene scene = new Scene(root, 800, 800);
      stage.setScene(scene);
      stage.show();

      SwingUtilities.invokeLater(new Runnable() {

      @Override
      public void run() {
      jPanel = new JPanel();
      jPanel.setBackground(Color.RED);
      swingNode.setContent(jPanel);
      }
      });
      }

      public static void main(String[] args) {
      launch(args);
      }
      }

      Attachments

        Issue Links

          Activity

            People

              ant Anton Tarasov (Inactive)
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported: