如何编辑JComboBox下拉箭头?

时间:2015-07-28 17:53:12

标签: java netbeans jcombobox

如何删除JComboBox下拉箭头的背景,只留下小三角形?下拉列表是使用Netbeans版本8中的JComboBox工具创建的。

1 个答案:

答案 0 :(得分:1)

@Drew我不认为OP希望按钮消失 - 他只是希望按钮没有箭头三角形以外的可见表现形式:

JComboBox<String> box = new JComboBox<>();
final Color bg = box.getBackground();
box.setUI(new BasicComboBoxUI() {
    @Override
    protected JButton createArrowButton() {
        JButton b = super.createArrowButton();
        b.setBackground(bg);
        b.setBorderPainted(false);
        return b; 
   }
});