ComboBox: made popup list wider if list item texts are longer than combo box width

This commit is contained in:
Karl Tauber
2019-09-26 10:35:19 +02:00
parent 84dc96d41a
commit fbfde043b3
5 changed files with 64 additions and 0 deletions

View File

@@ -341,6 +341,22 @@ public class FlatComboBoxUI
super( combo );
}
@Override
protected Rectangle computePopupBounds( int px, int py, int pw, int ph ) {
// get maximum display size of all items, ignoring prototype value
Object prototype = comboBox.getPrototypeDisplayValue();
if( prototype != null )
comboBox.setPrototypeDisplayValue( null );
Dimension displaySize = getDisplaySize();
if( prototype != null )
comboBox.setPrototypeDisplayValue( prototype );
// make popup wider if necessary
pw = Math.max( pw, displaySize.width );
return super.computePopupBounds( px, py, pw, ph );
}
@Override
protected void configurePopup() {
super.configurePopup();