1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -453,6 +453,31 @@ protected LayoutManager createLayoutManager() {
453
453
}
454
454
455
455
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
+
456
481
public void layoutContainer (final Container parent ) {
457
482
if (arrowButton != null && !comboBox .isEditable ()) {
458
483
final Insets insets = comboBox .getInsets ();
@@ -476,8 +501,6 @@ public void layoutContainer(final Container parent) {
476
501
477
502
if (editor != null ) {
478
503
final Rectangle editorRect = rectangleForCurrentValue ();
479
- editorRect .width += 4 ;
480
- editorRect .height += 1 ;
481
504
editor .setBounds (editorRect );
482
505
}
483
506
}
0 commit comments