Browse Source

Ensure state of renderer doesn't change before painting.

pull/222/head
weisj 4 years ago
parent
commit
779c7f64d3
  1. 6
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java

6
core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java

@ -206,9 +206,10 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants
@Override @Override
public void paint(final Graphics g, final JComponent c) { public void paint(final Graphics g, final JComponent c) {
if (!comboBox.isEditable()) { if (!comboBox.isEditable()) {
Rectangle rect = rectangleForCurrentValue();
Component currentValueRenderer = getRendererForCurrentValue(); Component currentValueRenderer = getRendererForCurrentValue();
paintBackground(g, c, currentValueRenderer); paintBackground(g, c, currentValueRenderer);
paintCurrentValue(g, rectangleForCurrentValue(), hasFocus, currentValueRenderer); paintCurrentValue(g, rect, hasFocus, currentValueRenderer);
} else { } else {
paintBackground(g, c, getEditorComponent()); paintBackground(g, c, getEditorComponent());
} }
@ -366,9 +367,8 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants
((JComponent) c).setOpaque(false); ((JComponent) c).setOpaque(false);
} }
boolean shouldValidate = c instanceof JPanel;
Rectangle r = new Rectangle(bounds); Rectangle r = new Rectangle(bounds);
currentValuePane.paintComponent(g, c, comboBox, r.x, r.y, r.width, r.height, shouldValidate); currentValuePane.paintComponent(g, c, comboBox, r.x, r.y, r.width, r.height, c instanceof JPanel);
// return opaque for combobox popup items painting // return opaque for combobox popup items painting
if (changeOpaque) { if (changeOpaque) {
((JComponent) c).setOpaque(true); ((JComponent) c).setOpaque(true);

Loading…
Cancel
Save