jdk icon indicating copy to clipboard operation
jdk copied to clipboard

6672644: JComboBox still scrolling if switch to another window and return back

Open DamonGuy opened this issue 1 year ago • 7 comments
trafficstars

In a JComboBox, if the user opens the dropdown list and clicks and holds the down-button, then ALT-TABs to switch focus, when the user re-focuses the frame with the JComboBox and opens the dropdown list again, the list will still be scrolling even though the down-button isn't pressed.

This isn't OS or L&F specific, although Aqua L&F does not have any directional arrows in the dropdown list (and is thus exempt). This led me to believe it could be handled in BasicComboBoxUI where focusLost and focusGain are used or isPopupVisible but the scroll behavior cannot be altered here. Likewise for BasicComboPopup where autoscroll is used. However, this behavior isn't related to autoscroll and is actually found in the JScrollbar of the JScrollpane inside of the JComboBox. The timer for the scroll action starts but is never stopped if focus is lost, so a new listener is created and used. The proposed solution uses KeyboardFocusManager to track the focus owner. The listener stops the scrollTimer when the focusOwner property is changed. With this change, the list no longer automatically scrolls when re-focused and instead opens normally.

The included test is manual due to the need to confirm that the list still scrolls after ALT-TABing. The L&F is set to Metal since it is the cross-platform lookandfeel and has directional buttons for the JScrollPane list.


Progress

  • [ ] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue

Issue

  • JDK-6672644: JComboBox still scrolling if switch to another window and return back (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20845/head:pull/20845
$ git checkout pull/20845

Update a local copy of the PR:
$ git checkout pull/20845
$ git pull https://git.openjdk.org/jdk.git pull/20845/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20845

View PR using the GUI difftool:
$ git pr show -t 20845

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20845.diff

Webrev

Link to Webrev Comment

DamonGuy avatar Sep 04 '24 00:09 DamonGuy

:wave: Welcome back dnguyen! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

bridgekeeper[bot] avatar Sep 04 '24 00:09 bridgekeeper[bot]

@DamonGuy This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

6672644: JComboBox still scrolling if switch to another window and return back

Reviewed-by: abhiscxk, psadhukhan

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 63 new commits pushed to the master branch:

  • 50c099d69e9cef5c38a2624d7c798360eb6c1fba: 8344799: Remove permissions checks from java.awt.Desktop
  • e21d06f488bce227eedc4c92d976301a7b54fda8: 8344338: javax/swing/JTextArea/bug4265784.java fails on Ubuntu 24.04.1
  • db44e97c5dfd286a58985be9b091fd43f5ad03be: 8344798: Shenandoah: Use more descriptive variable names in shPhaseTimings.cpp
  • c199f5326b8dd41f33a12e5db7552331e0844601: 8344336: SM cleanup of java.lang.System, Runtime, String, StackWalker
  • 0f458e2c3eb93641864085d18e49daf640cb3858: 8342903: Deprecate for removal java.awt.Window.getWarningString()
  • efeacfee015d1105dcd75e489d367a7716441fa8: 8344646: The libjsig deprecation warning should go to stderr not stdout
  • 22149063101f0c617d8ccaace659671a645d402e: 8272339: Update notes section from serialver man page
  • cee74f9e677e74deda72638bcc0a3e9307262938: 8338536: Permanently disable remote code downloading in JNDI
  • 7709d435d080778a45bd3eb9a5754e356e94e6de: 8344782: Cleanup left over doPrivileged calls and imports in java.desktop
  • e03b1506d3644f9e4053630adc4c0620eaef71c0: 8178966: Don't swallow early bootstrap exceptions in Boolean.getBoolean, Integer.getInteger and Long.getLong
  • ... and 53 more: https://git.openjdk.org/jdk/compare/f525290000bf8583617047aaeb894bf90332d2e9...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

openjdk[bot] avatar Sep 04 '24 00:09 openjdk[bot]

@DamonGuy The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

openjdk[bot] avatar Sep 04 '24 00:09 openjdk[bot]

@DamonGuy are you able to reproduce the issue on linux machine? I tried on windows and linux, was able to reproduce it only on windows. I checked on Ubuntu-22.04 and I can see the list is not scrolling and is stopped. Could you please confirm the same?

kumarabhi006 avatar Sep 04 '24 07:09 kumarabhi006

I can verify on linux machine that it is suto-scrolling but it is intermittent on windows as well as on linux. Sometimes the list is scrolling and sometimes it's not. Are you facing the same? To regain focus, if click on frame title bar then the intermittent issue can be observed.

kumarabhi006 avatar Sep 04 '24 07:09 kumarabhi006

@DamonGuy This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Oct 03 '24 21:10 bridgekeeper[bot]

@kumarabhi006 Tested with the additional changes I made. Looks like it's working now. No other tests are failing in CI with the changes either. Can you check it out again?

DamonGuy avatar Nov 05 '24 22:11 DamonGuy

/integrate

DamonGuy avatar Nov 22 '24 19:11 DamonGuy

Going to push as commit 11147046aa6102bc6e132d7b8c9d4e11db802002. Since your change was applied there have been 83 commits pushed to the master branch:

  • 98b667834c4a8f0d0ab54b8133061bc475674732: 8343741: SA jstack --mixed should print information about VM locks
  • 1b2d9cad532d9b047b8556ed8c9d75f83f75efe0: 8344881: Problemlist java/awt/Robot/InfiniteLoopException.java on Linux
  • 6aec2dcf76322ee92b62b5a063354057351d65e1: 8344788: Specify that the access control context parameters of Subject.doAsPrivileged are ignored
  • 079f503d962ad9e5ae4394c083e6877828c798ec: 8344568: Renaming ceil_log2 to log2i_ceil
  • 51763b67004a8b37d9bf4b8efef8aa1fa7bc9f4a: 8344525: Fix leftover ExceptionOccurred in java.base
  • 4b1653056d39db2c85989c787364e2646e5ef463: 8344795: Remove uses of AccessControlContext in java.desktop module
  • 5154b71637e685807952e3e776e4583f0a6280f6: 8343598: Since Checker can mark some preview elements as new even if bytecode reference is identical
  • 8b98f958dc1afedc02b9d9c98089d6cb1ca3a5b7: 8298387: Implement JEP 497: Quantum-Resistant Module-Lattice-Based Digital Signature Algorithm
  • 21e0fb8648d61f041a04d44ad6c46fc5efd86261: 8343529: serviceability/sa/ClhsdbWhere.java fails AssertionFailure: Corrupted constant pool
  • 13987b4244614d594dc8f94c288eddb6239a066f: 8298390: Implement JEP 496: Quantum-Resistant Module-Lattice-Based Key Encapsulation Mechanism
  • ... and 73 more: https://git.openjdk.org/jdk/compare/f525290000bf8583617047aaeb894bf90332d2e9...master

Your commit was automatically rebased without conflicts.

openjdk[bot] avatar Nov 22 '24 19:11 openjdk[bot]

@DamonGuy Pushed as commit 11147046aa6102bc6e132d7b8c9d4e11db802002.

:bulb: You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

openjdk[bot] avatar Nov 22 '24 19:11 openjdk[bot]