问题描述
我想自定义JComboBox
,所以我将模型与ListCellRenderer
一起使用,我的目标是通过将对象悬停为橙色来更改项目的背景,然后得到它。
但是我稍微改变了组合框的样式,它看起来有点金属质感,我怎么能使它看起来像原始的,传递指针时的背景颜色不是蓝色而是橙色,颜色代码我使用的是 [255,142,0]
public class PropertyCombo extends BasicComboBoxUI {
Color c = new Color(255,0);
public static ComboBoxUI createUI(JComponent com) {
return new PropertyCombo();
}
@Override
protected ListCellRenderer createRenderer() {
return new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> jlist,Object o,int i,boolean bln,boolean bln1) {
super.getListCellRendererComponent(jlist,o,i,bln,bln1);
jlist.setSelectionBackground(c);
return this;
}
};
}
}
cbx_name.setUI(PropertyCombo.createUI(this));
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)