不可编辑的JComboBox中所选项目的背景颜色 [英] Background color of the selected item in an uneditable JComboBox
本文介绍了不可编辑的JComboBox中所选项目的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
不可编辑的JComboBox中所选项目的背景颜色是一种蓝色:
The background color of the selected item in an uneditable JComboBox is a sort of blue:
有没有办法让它变成不同的颜色,例如白色?
Is there any way to make this a different color, such as white, for example?
推荐答案
这应该有效
jComboBox1.setRenderer(new DefaultListCellRenderer() {
@Override
public void paint(Graphics g) {
setBackground(Color.WHITE);
setForeground(Color.BLACK);
super.paint(g);
}
});
这篇关于不可编辑的JComboBox中所选项目的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文