Skip to content

Commit 644a430

Browse files
committed
8054572: [macosx] JComboBox paints the border incorrectly
Backport-of: 8082c24a0df3f4861ea391266bdfe6cdd1a77bab
1 parent 5217b07 commit 644a430

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxUI.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -453,6 +453,31 @@ protected LayoutManager createLayoutManager() {
453453
}
454454

455455
class AquaComboBoxLayoutManager extends BasicComboBoxUI.ComboBoxLayoutManager {
456+
protected Rectangle rectangleForCurrentValue() {
457+
int width = comboBox.getWidth();
458+
int height = 22;
459+
Insets insets = getInsets();
460+
int buttonSize = height - (insets.top + insets.bottom);
461+
if ( arrowButton != null ) {
462+
buttonSize = arrowButton.getWidth();
463+
}
464+
int midHeight = (comboBox.getHeight() - height - (insets.top + insets.bottom)) / 2 - 1;
465+
if (midHeight < 0) {
466+
midHeight = 0;
467+
}
468+
469+
if (comboBox.getComponentOrientation().isLeftToRight()) {
470+
return new Rectangle(insets.left, insets.top + midHeight,
471+
width - (insets.left + insets.right + buttonSize) + 4,
472+
height - (insets.top + insets.bottom));
473+
}
474+
else {
475+
return new Rectangle(insets.left + buttonSize, insets.top + midHeight,
476+
width - (insets.left + insets.right + buttonSize) + 4,
477+
height - (insets.top + insets.bottom));
478+
}
479+
}
480+
456481
public void layoutContainer(final Container parent) {
457482
if (arrowButton != null && !comboBox.isEditable()) {
458483
final Insets insets = comboBox.getInsets();
@@ -476,8 +501,6 @@ public void layoutContainer(final Container parent) {
476501

477502
if (editor != null) {
478503
final Rectangle editorRect = rectangleForCurrentValue();
479-
editorRect.width += 4;
480-
editorRect.height += 1;
481504
editor.setBounds(editorRect);
482505
}
483506
}

0 commit comments

Comments
 (0)