|
|
@ -213,13 +213,16 @@ 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) { |
|
|
|
paintBackground(g, c); |
|
|
|
|
|
|
|
if (!comboBox.isEditable()) { |
|
|
|
if (!comboBox.isEditable()) { |
|
|
|
paintCurrentValue(g, rectangleForCurrentValue(), hasFocus); |
|
|
|
Component currentValueRenderer = getRendererForCurrentValue(); |
|
|
|
|
|
|
|
paintBackground(g, c, currentValueRenderer); |
|
|
|
|
|
|
|
paintCurrentValue(g, rectangleForCurrentValue(), hasFocus, currentValueRenderer); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
paintBackground(g, c, getEditorComponent()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void paintBackground(final Graphics g, final JComponent c) { |
|
|
|
private void paintBackground(final Graphics g, final JComponent c, final Component currentValueRenderer) { |
|
|
|
final Container parent = c.getParent(); |
|
|
|
final Container parent = c.getParent(); |
|
|
|
if (parent != null && parent.isOpaque() && !c.isEnabled()) { |
|
|
|
if (parent != null && parent.isOpaque() && !c.isEnabled()) { |
|
|
|
g.setColor(parent.getBackground()); |
|
|
|
g.setColor(parent.getBackground()); |
|
|
@ -227,7 +230,9 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
boolean isCellEditor = ComboBoxConstants.isTreeOrTableCellEditor(c); |
|
|
|
boolean isCellEditor = ComboBoxConstants.isTreeOrTableCellEditor(c); |
|
|
|
Color bg = getBackground(comboBox); |
|
|
|
Color rendererBg = currentValueRenderer != null ? currentValueRenderer.getBackground() : null; |
|
|
|
|
|
|
|
Color bg = PropertyUtil.chooseColor(rendererBg, getBackground(comboBox)); |
|
|
|
|
|
|
|
|
|
|
|
Color splitBg = getArrowBackground(comboBox); |
|
|
|
Color splitBg = getArrowBackground(comboBox); |
|
|
|
Rectangle arrowRect = comboBox.isEditable() ? arrowButton.getBounds() : null; |
|
|
|
Rectangle arrowRect = comboBox.isEditable() ? arrowButton.getBounds() : null; |
|
|
|
DividedWidgetPainter.paintBackground((Graphics2D) g, c, arcSize, arrowRect, bg, splitBg, isCellEditor); |
|
|
|
DividedWidgetPainter.paintBackground((Graphics2D) g, c, arcSize, arrowRect, bg, splitBg, isCellEditor); |
|
|
@ -326,17 +331,20 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
public void paintCurrentValue(final Graphics g, final Rectangle bounds, final boolean hasFocus) { |
|
|
|
protected Component getRendererForCurrentValue() { |
|
|
|
ListCellRenderer<Object> renderer = comboBox.getRenderer(); |
|
|
|
return comboBox.getRenderer().getListCellRendererComponent(listBox, comboBox.getSelectedItem(), |
|
|
|
Component c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), |
|
|
|
|
|
|
|
comboBox.getSelectedIndex(), false, false); |
|
|
|
comboBox.getSelectedIndex(), false, false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void paintCurrentValue(final Graphics g, final Rectangle bounds, final boolean hasFocus, final Component c) { |
|
|
|
|
|
|
|
PropertyUtil.installFont(c, comboBox.getFont()); |
|
|
|
c.setFont(comboBox.getFont()); |
|
|
|
c.setFont(comboBox.getFont()); |
|
|
|
if (hasFocus && !isPopupVisible(comboBox)) { |
|
|
|
if (hasFocus && !isPopupVisible(comboBox)) { |
|
|
|
c.setForeground(listBox.getForeground()); |
|
|
|
PropertyUtil.installForeground(c, listBox.getForeground()); |
|
|
|
c.setBackground(listBox.getBackground()); |
|
|
|
PropertyUtil.installBackground(c, listBox.getBackground()); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
c.setForeground(getForeground(comboBox)); |
|
|
|
PropertyUtil.installForeground(c, getForeground(comboBox)); |
|
|
|
c.setBackground(getBackground(comboBox)); |
|
|
|
PropertyUtil.installBackground(c, getBackground(comboBox)); |
|
|
|
} |
|
|
|
} |
|
|
|
if (c instanceof JComponent) { |
|
|
|
if (c instanceof JComponent) { |
|
|
|
PropertyUtil.installBorder((JComponent) c, null); |
|
|
|
PropertyUtil.installBorder((JComponent) c, null); |
|
|
|