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

[JFXPanel] MacOS X issue with Clipboard between Swing and JavaFX



    • Bug
    • Resolution: Fixed
    • P3
    • 8u40
    • 8u20, 8u40
    • javafx
    • None
    • MacOS X 10.8.x, 10.9.x


      Dear JavaFX team,

      This issue is Mac OS X specific issue - the clipboard content for Swing controls are different from JavaFX controls. The test scenario contains JavaFX embedding in Swing via JFXPanel.

      Source code to reproduce it (class ClipboardBug):
      import java.awt.BorderLayout;
      import java.awt.Dimension;

      import javafx.application.Platform;
      import javafx.embed.swing.JFXPanel;
      import javafx.scene.Scene;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.VBox;
      import javafx.scene.web.WebView;

      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.JTextField;
      import javax.swing.SwingUtilities;

      public class ClipboardBug extends JFrame {
      private final JTextField txt = new JTextField("Swing JTextField");
      private final JFXPanel jfxPanel = new JFXPanel();

      public ClipboardBug() {
              Platform.runLater(new Runnable() {
                  public void run() {
                      TextField textField = new TextField("JavaFX input field");
                      WebView view = new WebView();
                      view.getEngine().loadContent("<html><body><input type=text value='HTML Text control'/></body></html>");
                      VBox hb = new VBox();
                      hb.getChildren().addAll(textField, view);
                      jfxPanel.setScene(new Scene(hb));
              JPanel panel = new JPanel(new BorderLayout());
              panel.add(txt, BorderLayout.NORTH);
              panel.add(jfxPanel, BorderLayout.CENTER);
              setPreferredSize(new Dimension(1024, 600));

      public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {

                  public void run() {
                   ClipboardBug test = new ClipboardBug();


      Steps to reproduce this issue:
      1. Compile and Run this sample on Mac OS X
      2. Select some text in "Swing's text field", press Command + C to copy it into clipboard
      3. Set focus inside JavaFX input field (2nd one) and press Command + V
      4. The copied text inserted. Now, select some text in JavaFX input field and Copy it via Command + C
      5. Try to paste it into Swing's text field (1st one) -> The inserted text would be equal to copied on step 2 (not at step 5).

      As discussed with Stephen Northover:
       - test application contains 2 JavaFX controls - easy input field + WebView
       - JavaFX uses/optimizes clipboard within the same scope and does not share it with Swing's controls
       - This issue is MacOS X specific - looks like, the ActionEvent binding to Command C+V are done different in JavaFX... may be it's an issue with key binding mapping.

      With Best Regards,
      Mykola Gorbarov


        Issue Links



              ant Anton Tarasov (Inactive)
              mykolagorjfx MykolaGorbarov_SAP (Inactive)
              0 Vote for this issue
              5 Start watching this issue