Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2609 > unrolled thread

List cell renderer with J

Started by"Karsten Wutzke" <karsten.wutzke@THRWHITE.remove-dii-this>
First post2011-04-27 15:40 +0000
Last post2011-04-27 15:40 +0000
Articles 4 — 3 participants

Back to article view | Back to comp.lang.java.gui


Contents

  List cell renderer with J "Karsten Wutzke" <karsten.wutzke@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
    Re: List cell renderer wi "bcd" <bcd@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
    Re: List cell renderer wi "Håkan Lane" <håkan.lane@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
      Re: List cell renderer wi "Karsten Wutzke" <karsten.wutzke@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000

#2609 — List cell renderer with J

From"Karsten Wutzke" <karsten.wutzke@THRWHITE.remove-dii-this>
Date2011-04-27 15:40 +0000
SubjectList cell renderer with J
Message-ID<1191925168.780092.148750@19g2000hsx.googlegroups.com>
  To: comp.lang.java.gui
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 ...?

Karsten

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

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#2620 — Re: List cell renderer wi

From"bcd" <bcd@THRWHITE.remove-dii-this>
Date2011-04-27 15:40 +0000
SubjectRe: List cell renderer wi
Message-ID<felndr$aft$1@orkan.itea.ntnu.no>
In reply to#2609
  To: comp.lang.java.gui
In article <1191925168.780092.148750@19g2000hsx.googlegroups.com>,
Karsten Wutzke  <kwutzke@web.de> 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@pvv.org - http://www.pvv.org/~bcd
                                    powered by emacs

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2621 — Re: List cell renderer wi

From"Håkan Lane" <håkan.lane@THRWHITE.remove-dii-this>
Date2011-04-27 15:40 +0000
SubjectRe: List cell renderer wi
Message-ID<470E5B8E.6CBD@operamail.com>
In reply to#2609
  To: comp.lang.java.gui
I think that you will have to write your own subclass of some
CellRenderer class. In what context (JList, JTree et.c) are you using
your JLabel? What you need to do would depend on that. I just spent
several hours learning this stuff today, so I don't mind helping you.
Just post some details about your code. 

Hokan

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2626 — Re: List cell renderer wi

From"Karsten Wutzke" <karsten.wutzke@THRWHITE.remove-dii-this>
Date2011-04-27 15:40 +0000
SubjectRe: List cell renderer wi
Message-ID<1192193001.632319.166990@i38g2000prf.googlegroups.com>
In reply to#2621
  To: comp.lang.java.gui
On 11 Okt., 19:21, H=E5kan Lane <H...@operamail.com> wrote:
> I think that you will have to write your own subclass of some
> CellRenderer class. In what context (JList, JTree et.c) are you using
> your JLabel? What you need to do would depend on that. I just spent
> several hours learning this stuff today, so I don't mind helping you.
> Just post some details about your code.
>
> H=E5kan

I'm using it in a JList. I already created a list cell renderer.
There's nothing special or otherwise difficult about the code in that
renderer class. When highlighting an entry in the list, I just miss
the "dotted border", as with standard JList or JTree entries.

What I mean here is I think, the border that gets displayed when the
entry is *focussed*...

Karsten

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web