Re: left justify icon in JTable cell
- From: usenet@xxxxxxx (Christian Kaufhold)
- Date: Sun, 24 Apr 2005 18:55:09 +0000 (UTC)
farseer <farseer@xxxxxxxxxxxxx> wrote:
> I have a custom cell renerer that adds and icon to in cell based on a
> condition. If the condition is met, the cell would contain both text
> and the icon. My question is, is there a way to have the icon appear
> left justified, while the text remains centered in cell?
>
> My guess is i my might have to create a panel or something, but i was
> hoping it was possible with a label or other lightweight
> components..(is JPanel light weight)?
Yes, it is. You could use a JPanel with two JLabels (one for the icon,
one for the text) and some layout that would put the icon label first
(left or right) and then the text label (with horizontalAlignment CENTER)
into the remaining space (or really centered).
In this simple case, one could also use a single JLabel and subclass
paint component to paint the extra icon.
Christian
.
- References:
- left justify icon in JTable cell
- From: farseer
- left justify icon in JTable cell
- Prev by Date: Re: Cursor in an uneditable textpane? (or getting chars as they are typed)
- Next by Date: Re: Table cell renderer problem - paint problem?
- Previous by thread: left justify icon in JTable cell
- Next by thread: Table cell renderer problem - paint problem?
- Index(es):
Relevant Pages
|