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

Using JavaFX and SwingNode - The Background and the JavaFX Button ist black

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 8u40
    • 8u31
    • javafx
    • None
    • Java SE 1.8 Development Kit 8 Update 31 (64bit)
      under Windows 8.1 Pro AMD

      Radeon HD 7800 Driver Version:
      14.501.1003-141120a-178000C

      I tried to use Swing Components in JavaFX with the SwingNode.
      After starting the application some parts of the window (the background and the JavaFX button) are black.
      After resizing the window, the window is repainted and looks like expected.
      Here is my code:

      public class MyTest extends Application {

          @Override
          public void start(Stage stage) {

              final SwingNode swingNode = new SwingNode();
              FlowPane pane = new FlowPane();

              Button btn = new Button("1");
              btn.setVisible(false);
              pane.getChildren().add(btn);

              createAndSetSwingContent(swingNode);
              pane.getChildren().add(swingNode);


              stage.setScene(new Scene(pane, 100, 50));

              stage.show();

              btn.setVisible(true);

          }

          private void createAndSetSwingContent(final SwingNode swingNode) {
              SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                      swingNode.setContent(new JButton("Click me!"));
                  }
              });
          }

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

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

              Created:
              Updated:
              Resolved:
              Imported: