|
This post originated from an RSS feed registered with Java Buzz
by News Manager.
|
Original Post: Customizing Cell Rendering
Feed Title: JavaWorld
Feed URL: http://www.javaworld.com/index.rss
Feed Description: JavaWorld.com: Fueling Innovation
|
Latest Java Buzz Posts
Latest Java Buzz Posts by News Manager
Latest Posts From JavaWorld
|
|
Swing's javax.swing.JList component and JavaFX's javafx.scene.control.ListView control let you customize how their various cells are rendered. In this post, I show you how to accomplish these tasks.
Customizing Cell Rendering in Swing JLists
Q: How do I customize how a JList instance's cells are rendered?
A: Swing provides the javax.swing.ListCellRenderer<E> interface to identify components that can be used as "rubber stamps" to render a JList instance's cells. This interface declares the following method:
Component getListCellRendererComponent(JList<? extends E> list,
E value,
int index,
boolean isSelected,
boolean cellHasFocus)
According to ListCellRenderer's Javadoc, getListCellRendererComponent() returns a java.awt.Component that's configured to display the specified value. The Component's paint() method is then called to render the cell.
To read this article in full or to leave a comment, please click here
Read: Customizing Cell Rendering