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?
93 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
Renderer
is only illusion, painting factory betweens value stored inXxxModel
andView
Renderer
is implemented forJList
(then forJComboBox
too),JTree
andJTable
(now we can forgot forJTreeTable
and its custom derivates)for rest of
Swing JComponents
you 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.