ComboBox: fixed StackOverflowError when switching LaF (#14)

This commit is contained in:
Karl Tauber
2019-10-20 20:04:10 +02:00
parent f53f205f52
commit f9d2312b3a
2 changed files with 22 additions and 15 deletions

View File

@@ -8,6 +8,7 @@ FlatLaf Change Log
- OptionPane: Fixed rendering of longer HTML text. (issue #12) - OptionPane: Fixed rendering of longer HTML text. (issue #12)
- EditorPane and TextPane: Fixed font and text color when using HTML content. - EditorPane and TextPane: Fixed font and text color when using HTML content.
(issue #9) (issue #9)
- ComboBox: Fixed `StackOverflowError` when switching LaF. (issue #14)
- SwingX: Support `JXBusyLabel`, `JXDatePicker`, `JXHeader`, `JXHyperlink`, - SwingX: Support `JXBusyLabel`, `JXDatePicker`, `JXHeader`, `JXHyperlink`,
`JXMonthView`, `JXTaskPaneContainer` and `JXTaskPane`. (issue #8) `JXMonthView`, `JXTaskPaneContainer` and `JXTaskPane`. (issue #8)

View File

@@ -368,9 +368,9 @@ public class FlatComboBoxUI
@SuppressWarnings( { "rawtypes", "unchecked" } ) @SuppressWarnings( { "rawtypes", "unchecked" } )
private class FlatComboPopup private class FlatComboPopup
extends BasicComboPopup extends BasicComboPopup
implements ListCellRenderer
{ {
private CellPaddingBorder paddingBorder; private CellPaddingBorder paddingBorder;
private final ListCellRenderer renderer = new PopupListCellRenderer();
FlatComboPopup( JComboBox combo ) { FlatComboPopup( JComboBox combo ) {
super( combo ); super( combo );
@@ -405,7 +405,7 @@ public class FlatComboBoxUI
protected void configureList() { protected void configureList() {
super.configureList(); super.configureList();
list.setCellRenderer( this ); list.setCellRenderer( renderer );
} }
@Override @Override
@@ -416,11 +416,16 @@ public class FlatComboBoxUI
super.propertyChange( e ); super.propertyChange( e );
if( e.getPropertyName() == "renderer" ) if( e.getPropertyName() == "renderer" )
list.setCellRenderer( FlatComboPopup.this ); list.setCellRenderer( renderer );
} }
}; };
} }
//---- class PopupListCellRenderer -----
private class PopupListCellRenderer
implements ListCellRenderer
{
@Override @Override
public Component getListCellRendererComponent( JList list, Object value, public Component getListCellRendererComponent( JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus ) int index, boolean isSelected, boolean cellHasFocus )
@@ -439,6 +444,7 @@ public class FlatComboBoxUI
return c; return c;
} }
} }
}
//---- class CellPaddingBorder -------------------------------------------- //---- class CellPaddingBorder --------------------------------------------