The moose likes Swing / AWT / SWT and the fly likes Rendering Labels with icons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Rendering Labels with icons" Watch "Rendering Labels with icons" New topic

Rendering Labels with icons

Barry Brashear
Ranch Hand

Joined: Jun 05, 2001
Posts: 303
I have a cell in a JTable that in some situations has an icon to the left
of it in the same cell. I would like the text to be aligned on the right
and the icons on the left. How do I do that?

Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
The default render is a subclass of JLabel, so you can use JLabel methods to alter its look, like it's alignment properties. One thing I've found handy for aligning is to use an empty icon to preserve alignments:

There is no emoticon for what I am feeling!
I agree. Here's the link:
subject: Rendering Labels with icons
jQuery in Action, 3rd edition