I have a custom cell renderer for a JList which displays a nested JList inside it with another custom cell renderer that displays a button. The problem I’m having is that any user inputs(e.g. mouse clicks on the buttons, scrolling action) doesn’t get handled and the nested JList becomes unreponsive(but it still paints properly whenever I resize the window). Is there any way to solve this issue?
Share
Like camickr said, Renderers just paint the image and are not real components.
One way to get around this is to use a single-column JTable, instead of a JList, where you can set CellEditors, which are real components (but only once that cell gains focus).
But it actually may be easier to create a panel with a scroll pane that listens to ListData events from a ListModel and adds and removes your components as necessary. That’s what I ended up going with the last time I had this problem, it was a bit more elegant.
Although, if you just have a single button, the JTable may work quite well.