JDK-8090267 : JFXPanel Input Problem
  • Type: Bug
  • Component: javafx
  • Sub-Component: swing
  • Affected Version: 7u6,8,9,10
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2012-08-23
  • Updated: 2024-07-23
  • Resolved: 2024-01-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
jfx23 b02Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Description
When I input Japanse (IME on) to the TextFIeld, which is on JFXPanel, 
small window for inputting appears on top-left side of screen, and I cannot input directly..

see attachment image file.

it works, but looks crap.

thanks.



1. start the program below
2. IME on
3. input to the TextField
4. result [image|http://pc.gban.jp/?p=45667.png]

package sample;

import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;

import javax.swing.JFrame;
import javax.swing.WindowConstants;

public class Test {

public static void main(String[] args) {
final JFXPanel panel = new JFXPanel();
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setContentPane(panel);
frame.setSize(100, 100);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
Platform.runLater(new Runnable() {

@Override
public void run() {
GridPane root = new GridPane();
root.addRow(0, new TextField());
Scene scene = new Scene(root);
panel.setScene(scene);
}
});
}
}
Comments
A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jfx/pull/1337 Date: 2024-01-16 17:59:42 +0000
23-07-2024

Changeset: 11706581 Author: Martin Fox <mfox@openjdk.org> Date: 2024-01-23 21:23:22 +0000 URL: https://git.openjdk.org/jfx/commit/11706581053ca3fc38b175882e573858d0d42020
23-01-2024

OK, assigning back to you.
19-01-2024

[~kcr] ANy reason why you assigned to Martin as the fix proposed was initially proposed by me so I presume I should get credited partially for it so this bug fix should be in my name.. 8322784 fix ha no bearing with this and this fix can be separate in my opinion...although together it makes more sense so I did not object..
19-01-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jfx/pull/1169 Date: 2023-07-04 05:54:54 +0000
04-07-2023

I tried inserting "suzukihonami" in full-width katakana, press "space". Then I need to press" enter" else it was not taking the arrow puts. I then pressed left-right arrows several times but could not reproduce NPE (attached snapshot). I created InputMethodRequestsAdapter with null fxRequests initially before scene is set as the decision to show native input window is made before that but once scene is set, it overrides with valid fxRequests in setEmbeddedScene().
27-11-2017

With your fix you are creating InputMethodRequestsAdapter with null fxRequests, but this class is not ready for it. You can easily get a NPE. E.g it happens with full size Katakana active: try to type "suzukihonami", then press space button and play with arrow button.
24-11-2017

For swing-interop case, WmImeStartComposition starts composition in native ImmSetCompositionWindow window as "m_useNativeCompWindow" below is true for FX http://hg.openjdk.java.net/jdk10/client/file/5a270d2dfa5d/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp#l3957 m_useNativeCompWindow is true because during sun.awt.im.InputContext#focusGained() calls activateInputMethod which calls WInputMethod.activate() which calls haveActiveClient() which checks for clientComponent.getInputMethodRequests(). Now, in JFXPanel, getInputMethodRequests() returns null as setEmbeddedScene() is not called yet. Since getInputMethodRequests() returns null, haveActiveClient() is false which calls enableNativeIME() with 1 [thereby native composition window is enabled] http://hg.openjdk.java.net/jdk10/client/file/5a270d2dfa5d/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java#l311 Proposed fix is to ensure there is an active client "initially" so that enableNativeIME() is called with 0 and no native compostion window is shown. getInputMethodRequests() is called in setEmbeddedScene() so as to make sure getInputMethodRequest() is initialised to correct "InputMethodSupport.InputMethodRequestsAdapter.fxRequests" object and not NULL. Request to review this fix http://cr.openjdk.java.net/~psadhukhan/fx/8090267/webrev.00/
02-11-2017

The issue is not reproducible in fx app with TextField so it is a swing-interop issue. When run in normal fx mode, it calls GlassWindow:WindowProc WM_IME_STARTCOMPOSITION which calls HandleViewInputMethodEvent whereas running in swing-interop mode, it calls JDK's AwtComponent:WindowProc WM_IME_STARTCOMPOSITION which does not call GlassWindow:HandleViewInputMethodEvent Seems like swing component does not have access to FX textfield window for WM_IME_STARTCOMPOSITION, which is why separate input method window is used -------------------------- public class JapaneseIMETest extends Application { static boolean useSwing = true; @Override public void start(Stage primaryStage) throws Exception { GridPane root = new GridPane(); root.addRow(0, new TextField()); Scene scene = new Scene(root); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { if (!useSwing) launch(args); else { final JFXPanel panel = new JFXPanel(); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setContentPane(panel); frame.setSize(100, 100); frame.setLocationRelativeTo(null); frame.setVisible(true); Platform.runLater(new Runnable() { @Override public void run() { GridPane root = new GridPane(); root.addRow(0, new TextField()); Scene scene = new Scene(root); panel.setScene(scene); } }); } } }
25-10-2017

I could not reproduce with JTextArea in swing app so it's not a swing problem...But could reproduce with fx testcase...could be swing-interop or a controls issue. public class JTextFieldTest { public static void main(String[] args) { SwingUtilities.invokeLater(() -> { JFrame frame = new JFrame(); //JTextField field = new JTextField(20); JTextArea field = new JTextArea(10,10); frame.add(field); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }); } }
24-10-2017

This is likely a swing interop bug, not a JavaFX controls bug.
29-06-2017

Received same report JDK-8183204, which is is reproducible in 8u60, 8u131, 8u152, 9ea+176.
29-06-2017

Not exactly sure what's happening unless digging deep, but it's likely that on-the-spot will not work with Swing-embed environment.
27-08-2012