Java 更改JComboBox箭头';背景色

Java 更改JComboBox箭头';背景色,java,swing,jcombobox,Java,Swing,Jcombobox,我发现: 如何准确地“将图标绘制到BuffereImage的图形上下文”?如下所示: int componentCount = comboBox.getComponentCount(); for (int i = 0; i < componentCount; i++) { Component component = comboBox.getComponent(i); if (component instanceof MetalComboBox

我发现:

如何准确地“将图标绘制到BuffereImage的图形上下文”?

如下所示:

    int componentCount = comboBox.getComponentCount();
    for (int i = 0; i < componentCount; i++) {
        Component component = comboBox.getComponent(i);
        if (component instanceof MetalComboBoxButton) {
            MetalComboBoxButton metalComboBoxButton =
                (MetalComboBoxButton) component;
            Icon comboIcon = metalComboBoxButton.getComboIcon();
            BufferedImage bufferedImage =
                new BufferedImage(
                    comboIcon.getIconWidth(),
                    comboIcon.getIconHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            comboIcon.paintIcon(
                metalComboBoxButton, bufferedImage.getGraphics(), 0, 0);
        }
    }
int componentCount=comboBox.getComponentCount();
对于(int i=0;i< /代码> 作为替代,考虑使用<代码> CuBoBOXUI中的自定义实例,如下面所示。

    int componentCount = comboBox.getComponentCount();
    for (int i = 0; i < componentCount; i++) {
        Component component = comboBox.getComponent(i);
        if (component instanceof MetalComboBoxButton) {
            MetalComboBoxButton metalComboBoxButton =
                (MetalComboBoxButton) component;
            Icon comboIcon = metalComboBoxButton.getComboIcon();
            BufferedImage bufferedImage =
                new BufferedImage(
                    comboIcon.getIconWidth(),
                    comboIcon.getIconHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            comboIcon.paintIcon(
                metalComboBoxButton, bufferedImage.getGraphics(), 0, 0);
        }
    }