Background color of the selected item in an uneditable JComboBox

前端 未结 3 473
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 00:20

The background color of the selected item in an uneditable JComboBox is a sort of blue:

\"alt

Is

3条回答
  •  天涯浪人
    2020-12-02 01:18

    This should work

    jComboBox1.setRenderer(new DefaultListCellRenderer() {
        @Override
        public void paint(Graphics g) {
            setBackground(Color.WHITE);
            setForeground(Color.BLACK);
            super.paint(g);
        }
    });
    

提交回复
热议问题