-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
6672644: JComboBox still scrolling if switch to another window and return back #20845
Conversation
👋 Welcome back dnguyen! A progress list of the required criteria for merging this PR into |
@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:
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
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 |
Webrevs
|
@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 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? |
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java
Outdated
Show resolved
Hide resolved
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java
Show resolved
Hide resolved
@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! |
@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? |
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java
Outdated
Show resolved
Hide resolved
if (incrButton.isFocusPainted()) { | ||
incrButton.doClick(); | ||
} else if (decrButton.isFocusPainted()) { | ||
decrButton.doClick(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this doClick block is required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scrollbar increase and decrease buttons stay visually clicked down. Trying to change setFocusPainted
or setSelected
didn't seem to resolve this. However, adding a doClick
resolves it and doesn't seem to interfere with the positioning of the scrolled item.
To be sure, I ran this on CI on all OS's and I didn't run into an issue. I'm open to other suggestions for fixing this visually, but this seemed like the cleanest way to do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we dont press on down-arrow button but press on the down viewport area, in which case doesn't it get reproduced?
Also doClick spec says
"Programmatically perform a "click". This does the same
* thing as if the user had pressed and released the button.
* The button stays visually "pressed" for <code>pressTime</code>
* milliseconds."
which does not seem to be right for this case..
What if you try to check button isPressed() and if so, do button setPress(false)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't think about that scenario. isPressed()
definitely makes more sense then. I've updated it to that.
Tested it and seems to work just as well. Thanks for the suggestion.
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java
Outdated
Show resolved
Hide resolved
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java
Outdated
Show resolved
Hide resolved
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look good to me now. Tested in linux platform and it worked as expected.
/integrate |
Going to push as commit 1114704.
Your commit was automatically rebased without conflicts. |
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 usesKeyboardFocusManager
to track the focus owner. The listener stops thescrollTimer
when thefocusOwner
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
Issue
Reviewers
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
Using Webrev
Link to Webrev Comment