JDK-8183204 : On using JTextArea with SwingNode, IME's on-the-spot does not work fine
  • Type: Bug
  • Component: javafx
  • Sub-Component: swing
  • Affected Version: 8,9
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows
  • CPU: x86_64
  • Submitted: 2017-06-29
  • Updated: 2024-01-29
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
tbdUnresolved
Related Reports
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 9-ea+174)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+174, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Japanese Environment

A DESCRIPTION OF THE PROBLEM :
When I input Japanese Text with IME to JTextArea on SwingNode, a small input window is shown like JDK-8090267.
So, on-the-spot does not work with Swing component embedded on SwingNode.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Execute the attached sample code
2. Input text with IME on


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The on-the-spot  behavior.
ACTUAL -
The root-window behavior.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class SwingNodeTest extends Application {

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

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("TextArea Test");
        Group root = new Group();
        Scene scene = new Scene(root, 600, 330, Color.WHITE);

        SwingNode swingNode = new SwingNode();
        root.getChildren().add(swingNode);

        final JTextArea jTextArea = new JTextArea();
        try {
            SwingUtilities.invokeAndWait(() -> {
                jTextArea.setLineWrap(true);
                jTextArea.setColumns(10);
                jTextArea.setRows(10);
            });
        } catch (InterruptedException | InvocationTargetException ex) {
            ex.printStackTrace();
        }
        
        swingNode.setContent(jTextArea);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
---------- END SOURCE ----------


Comments
I looked through the code and did a few quick tests on the various desktop platforms. From what I can tell the SwingNode doesn't meet the JavaFX conditions for IM input; it doesn't provide InputMethodRequests and it doesn't have the onInputMethodTextChanged property set. So JavaFX tells the platform code to disable IM input altogether. When IM input is disabled on Windows the IM window still appears and text gets delivered to the node. The real bug is that the IM window is showing up at all (see JDK-8088113). I suspect the OS is doing something tricky and delivering the text as a series of WM_CHAR events but haven't verified that. According to the JDK-8088113 write-up Linux is doing the right thing and not showing the IM window. On Mac we currently split the difference, the IM window appears but the text it generates gets discarded. That will be fixed with the PR for JDK-8301900 which will ensure the IM window never appears. IMHO we should fix JDK-8088113 to ensure the IM window doesn't appear and then hook up the InputMethodRequests and InputMethod events correctly in SwingNode to get it back.
29-01-2024

[~mfox] For this similar IME issue, Do you think we need WM_IME_SETCONTEXT handler in GlassWindow.m#WindowProc as in AWT we do https://github.com/openjdk/jdk/blob/65d6bc1d4c1054e82ace2355d6802e0a7ba24a7f/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp#L3942-L3958
29-01-2024

It's not a duplicate. In Swing for Japanese input in JTextArea, WM_IME_SETCONTEXT is called to stop showing native window http://hg.openjdk.java.net/jdk10/client/file/4c2e14b481f9/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp#l3932 but in fx swingnode, WM_IME_SETCONTEXT is not called causing native window to be shown.
02-11-2017

This is not necessarily a duplicate of JDK-8090267. That bug was in JFXPanel, while this bug is in SwingNode.
01-11-2017

Verified test case and issue is reproducible in 8u60, 8u131, 8u152, 9ea+176. Closing this as duplicate of JDK-8090267
29-06-2017