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() {
super();
Platform.runLater(new Runnable() {
@Override
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);
getContentPane().add(panel);
setPreferredSize(new Dimension(1024, 600));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
}
public static void main(String[] args) {
Platform.setImplicitExit(false);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ClipboardBug test = new ClipboardBug();
test.setVisible(true);
}
});
}
}
******
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
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() {
super();
Platform.runLater(new Runnable() {
@Override
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);
getContentPane().add(panel);
setPreferredSize(new Dimension(1024, 600));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
}
public static void main(String[] args) {
Platform.setImplicitExit(false);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ClipboardBug test = new ClipboardBug();
test.setVisible(true);
}
});
}
}
******
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
- relates to
-
JDK-8096542 [JFXPanel] back out fix for RT-38922
-
- Resolved
-