RFR: 8319880: JTextField text selection doesn't stop if ended during loss of window focus [v3]

Alexander Zuev kizune at openjdk.org
Wed Dec 3 21:38:47 UTC 2025


On Wed, 3 Dec 2025 10:56:24 GMT, Anass Baya <abaya at openjdk.org> wrote:

>> **Analysis :** 
>> The issue is that on Win32, if the window is not active, we dont receive mouse events because we release the capture
>>  So the problem is the following:
>> We start selecting text from the right to the extreme left.
>> Then we switch to another window( the window lose focus ), and we release the mouse
>> But when we return to the window, the caret drag is still active and does not stop. as the window did not recieved the mouse release event
>> 
>> **Proposed fix:**
>> In the Caret class, we added a logic to ignore the drag if the focus was lost due to window switching unless a new mouse press happens
>
> Anass Baya has updated the pull request incrementally with one additional commit since the last revision:
> 
>   The issue occurs only on Wnidows

test/jdk/javax/swing/JTextField/TextSelectionFocusLoss/TextSelectionFocusLoss.java line 72:

> 70:             robot.delay(500);
> 71: 
> 72:             Point location = textField.getLocationOnScreen();

These calls are still need to happen on EDT.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28582#discussion_r2586688264


More information about the client-libs-dev mailing list