Archives

Meta

Subscribe

Left Dot Renderer

The default renderer for a JTable uses a JLabel to provide the rendering. When the text on the label is truncated, the text is displayed left justified with trailing dots. There may be occasions when the trailing part of the text is more important than the start of the text and you would rather have the text right justified with leading dots. We can’t easily change the default behavour of a label, but we can change the behavour of the renderer.

Of course you could just increase the column width to see all the text and that is now easier thanks to the TableColumnAdjuster described in an earlier entry. However, this entry is about customizing the rendering. The LeftDotRenderer will display the text normally in the table column as long as the text fits in the width of the table column. When the text is too long to display completely, the renderer will determine the number of characters that can be displayed and then insert “…” at the start of the text to give the desired effect of right justifying the renderer.

Get The Code

See Also

Related Reading

Like this:

LikeLoading...

Related

This entry was posted on November 12, 2008 at 12:19 pm and is filed under Classes, Swing.
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.