If you have a ListCellRenderer
, simply invoke getListCellRendererComponent()
with the appropriate values, and then invoke setBounds(x, y, w, h)
and paint(g)
on the returned component (which is all normal cases is the renderer itself) to paint it as it would be in a list.
How can I use a custom JList renderer's results outside of a JList?
-
29-08-2022 - |
Question
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?
Solution 2
OTHER TIPS
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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow