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

Carriage returns ignored in WebView text areas when embedded in a JFXPanel

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8
    • 7u25
    • javafx
    • Linux, Java 1.7.0_25 (issue also reproduced on Windows 7).

    Description

      When typing in the WebView text areas of a "pure" JavaFX application, carriage returns result in line breaks in the text area:

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.web.WebEngine;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      public class PureJFX extends Application {
          public static void main(String[] args) {
              launch(args);
          }

          @Override
          public void start(Stage stage) throws Exception {
              WebView webView = new WebView();
              WebEngine webEngine = webView.getEngine();
              webEngine.loadContent("<textarea rows='5' cols='25'></textarea>");
              stage.setScene(new Scene(webView));
              stage.show();
          }
      }

      However, when the WebView is used in a mixed Swing and JavaFX application, using the JFXPanel, carriage returns are ignored:

      import javax.swing.JFrame;
      import javax.swing.SwingUtilities;

      import javafx.application.Platform;
      import javafx.embed.swing.JFXPanel;
      import javafx.scene.Scene;
      import javafx.scene.web.WebEngine;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      public class SwingJFX {
          public static void main(String[] args) {
              new SwingJFX();
          }

          public SwingJFX() {
              SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                      JFrame frame = new JFrame();
                      frame.setSize(640, 480);
                      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

                      final JFXPanel panel = new JFXPanel();
                      frame.getContentPane().add(panel);
                      frame.setVisible(true);

                      Platform.runLater(new Runnable() {
                          @Override
                          public void run() {
                              WebView webView = new WebView();
                              WebEngine webEngine = webView.getEngine();
                              webEngine.loadContent("<textarea rows='5' cols='25'></textarea>");
                              panel.setScene(new Scene(webView));
                          }
                      });
                  }
              });
          }
      }

      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: