Re: List cell renderer with JLabel: selected border



In article <1191925168.780092.148750@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Karsten Wutzke <kwutzke@xxxxxx> wrote:
Hello!

When using a custom cell renderer (JLabel subclass), I noticed the
border of a selected item is not drawn. How can I achieve a border
like with the default renderer, the "yellow dots" around the entries,
as with a standard JList or JTree for example.

How do I do it? Change the JLabel super class to ...?

You typically call label.setBorder() with an appropriate Border
object.

Swing apparantly uses
UIManager.getBorder("Table.focusSelectedCellHighlightBorder")
when that is available, and
UIManager.getBorder("Table.focusCellHighlightBorder")
when it is not.

(This is from the source for
javax.swing.table.DefaultTableCellRenderer in Java 1.6. Other versions
may be different.)

Karsten

PS: I need icons to be displayed on the left hand side.

If you want the icons to be to the left of the border, then you would
need to have a JPanel with two JLabels inside it. One JLabel would be
to the left and hold the icons but show no border while the other
JLabel would be to the right and hold the text as well as the border.

Cheers
Bent D
--
Bent Dalager - bcd@xxxxxxx - http://www.pvv.org/~bcd
powered by emacs
.