JDK-8076455 : IME Composition Window is displayed on incorrect position
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt:i18n
  • Affected Version: 8,9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-04-01
  • Updated: 2017-10-03
  • Resolved: 2015-04-27
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.
JDK 6 JDK 7 JDK 8 JDK 9 Other
6u151Fixed 7u91Fixed 8u60Fixed 9 b65Fixed openjdk7uFixed
OS  : Windows 7
JDK : jdk 7/8

The problem occurs when all the following conditions are met.
1. LayoutManager with territory not including client area base point of a
frame is used when GridLayout or FlowLayout is divided into horizontal side.
2. Attach a heavy weight container on 1's area
3. Attach input method client of active client on 2's container

The test case IMFDemo.java made by the issue reporter is based on
IMFDemo. When to input text in active client through IME, composition
Windows is displayed on left side(see attached GridIMFDemo.png). In
jdk6, it is shown below the component(GridIMFDemo6.png).
The root cause is thought in awt_Comoponent.cpp.

void AwtComponent::OpenCandidateWindow(int x, int y)
    UINT bits = 1;
    RECT rc;
    GetWindowRect(GetHWnd(), &rc);  // *1 getting RECT from focused peer

    for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
        if ( m_bitsCandType & bits )
            SetCandidateWindow(iCandType, x-rc.left, y-rc.top);
    if (m_bitsCandType != 0) {
        // REMIND: is there any chance GetProxyFocusOwner() returns NULL
        ::DefWindowProc(ImmGetHWnd(),   // *2 sending message to frame
                        WM_IME_NOTIFY, IMN_OPENCANDIDATE, m_bitsCandType);

Datum of the rectangle shown *1 is obtained from focused peer, but in
*2, message is processed by the frame Window which controls HIMC. As a
result, the peer that doesn't contain base point of frame client area
is out of alignment. 
Verified with jdk9 build 134 on Windows 7, passed.

In the given scenario, there are at least two reasons for the incorrect position of IME candidate window: * we translate the candidate window position using wrong heavyweight component (the panel, instead of the top level frame, where IME_NOTIFY message is actually handled) * the position of candidate window, requested by the java IME client is not precise enough