I basically have a JTree where I show certain information. In one of the “sub-trees” I got a panel which consists of a panel with GridLayout(0,2) and a JPanel as well as a combobox.
I’ve noticed that no components in my tree react on input. This of course means that my combobox won’t react when I try to click on it. I tried to implement a default cell editor, which worked but not like I wanted to. It basically opened the menu but when I selected one of the items it replaced the JLabel so only the combobox was visible.
Pictures
Before clicking on the box 
After clicking on the box 
Code that I tried with
TreeCellEditor editor = new DefaultCellEditor(blockedAlternatives);
infoTree.setEditable(true);
infoTree.setCellEditor(editor);
I obviously don’t want to be able to edit the whole tree, I just want to be able to show the combobox’s menu. I just took this code from the web for testing.
Any ideas?
Well that is what you’d excpect as thats how the
DefaultCellEditor(JComboBox jcb)is meant to be:You could try making your own
DefaultCellEditorand overridegetTableCellEditorComponent()and then return aJPanelwhich holds theJLabelandJComboBox, something like:then:
you may have to override a few other methods too. I was just showing the logic
References:
Creating a DefaultCellEditor: JComboBox
extends DefaultCellEditor