RFR: 8054572: [macosx] JComboBox paints the border incorrectly [v2]

Damon Nguyen dnguyen at openjdk.org
Thu Aug 11 14:09:43 UTC 2022


On Tue, 12 Jul 2022 22:56:37 GMT, Damon Nguyen <dnguyen at openjdk.org> wrote:

>> When a JComboBox is editable, the button segment of the combo box is misaligned vertically and has a different height. This change fixes these issues and adds a manual test that checks the appearance of an editable and non-editable JComboBox.
>> 
>> One of the discussions revolving this issue is the native macOS appearance of editable JComboBoxes. After looking through native macOS apps, the only one found is in System Preferences > Date & Time. The problem here is that the native equivalent found here uses a blue button with a single down arrow as the button's symbol. The current swing implementation uses a white button with an up & down arrow symbol for the button. A JRS widget button that has this blue button with a single downward arrow exists but does not support text fields.
>> 
>> As such, I believe the best fix for this issue is to mainly fix the alignment and sizing issue. I looked through Apple's documentation for these UI elements but editable JComboBoxes aren't specifically listed anywhere. Similarly, there's barely any editable JComboBoxes used in native mac apps (only the date & time). So, I don't think it's a major issue if JComboBox does not exactly match the example found in Date & Time.
>
> Damon Nguyen has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
> 
>  - Updated method names for PassFailJFrame
>  - Merge branch 'openjdk:master' into 8054572/JComboBoxBorderAlignmentFix
>  - Removed commented lines. Added newlines.
>  - Updated test with PassFailJFrame
>  - Added test
>  - Adjusted height and coordinate for editable JComboBox

The solution I worked towards was to match the behavior of the non-editable combo box in Aqua L&F. This is because, as previously mentioned, the button's visual size can't change. If the arrow button's size is increased, space will be dedicated for the button in its container and the button will function if clicked within that space but the button would still appear to be the same size (which would be too small for larger text fields). 

So, the text field will not resize in height according to the font and the font would remain the larger font size of 30 in this example. This requires me to override the rectangle calculation method and update the logic for an editable text field of varying font sizes to correctly center the text field to be aligned with the arrow button.

<img width="577" alt="Screen Shot 2022-08-11 at 6 55 47 AM" src="https://user-images.githubusercontent.com/96267980/184151129-8615a505-e8cd-4ffa-9184-52187f713fc5.png">

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

PR: https://git.openjdk.org/jdk/pull/9473



More information about the client-libs-dev mailing list