I have a custom renderer that works just perfectly - how can I use it as a "drawing engine" to produce the same objects it would produce in a JList?
How can I use a custom JList renderer's results outside of a JList?
133 views Asked by tM -- At
2
There are 2 answers
4
On
how can I use it as a "drawing engine" to produce the same objects it would produce in a JList?
AFAIK
Rendereris only illusion, painting factory betweens value stored inXxxModelandViewRendereris implemented forJList(then forJComboBoxtoo),JTreeandJTable(now we can forgot forJTreeTableand its custom derivates)for rest of
Swing JComponentsyou have to use standard paint, more informations, wroking code examples in official Oracle tutorials
If you have a
ListCellRenderer, simply invokegetListCellRendererComponent()with the appropriate values, and then invokesetBounds(x, y, w, h)andpaint(g)on the returned component (which is all normal cases is the renderer itself) to paint it as it would be in a list.