我不想改变JComboBox的弹出/选择部分的边框。
请注意,UI是BasicComboBoxUI
我试过了:
weaponCB.setRenderer(new DefaultListCellRenderer() {
@Override
public void paint(Graphics g) {
setBorder(whiteBorder)
//whiteBorder is a white border
super.paint(g);
}
});
但它给了我这个:
和
for (int i=0; i<weaponCB.getComponentCount(); i++)
{
if (weaponCB.getComponent(i) instanceof AbstractButton)
{
((AbstractButton)weaponCB.getComponent(i)).setBorder(whiteBorder);
}
}
但它给了我这个:
我不想是这样的:(它是在photoshop中完成的) 我不介意它是不是完全相同,我只是不相似。
有没有人对如何做到这一点有任何想法?
答案 0 :(得分:2)
这样的工作:
Object child = comboBox.getAccessibleContext().getAccessibleChild(0);
BasicComboPopup popup = (BasicComboPopup)child;
JList list = popup.getList();
list.setBorder( whiteBorder );