0

I have created a JComboBox with a custom ListCellRenderer (a JButton) as below:

JButton b1 = new JButton("One");
JButton b2 = new JButton("Two");
JButton b3 = new JButton("Three");

JButton[] buttonList = {b1, b2, b3};

JComboBox box = new JComboBox(buttonList);
box.setRenderer(new CellRenderer());
//...


/**************** Custom Cell Renderer Class ****************/
class CellRenderer implements ListCellRenderer {

        public Component getListCellRendererComponent(JList list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {            
            JButton button = (JButton) value;
            return button;           
}

I have set button actions separately and all are works fine except when I am clicking a button from the combo box it doesn't shows the button clicking visual effect.

How to show the clicking visual effect of a JButton inside a JComboBox?

Andrew Thompson
  • 166,747
  • 40
  • 210
  • 420
Harsha
  • 3,428
  • 19
  • 50
  • 73

1 Answers1

0

I think I found the reason for not showing the visual clicking effects inside a JComboBox From this --> Stackoverflow question

Community
  • 1
  • 1
Harsha
  • 3,428
  • 19
  • 50
  • 73