change textfont in specified rows/elements in a JList

T

Tom

Hi,

I have a JList and i want some of it's rows/elements to show in a different
font(i.e bold) than the rest. Can you change the output text looks to specified
elements in the JList? How?

Best regards
Tom
 
R

Roedy Green

I have a JList and i want some of it's rows/elements to show in a different
font(i.e bold) than the rest. Can you change the output text looks to specified
elements in the JList? How?

read the docs in JList on using a ListCellRenderer. Are you sure you
mean JList not JTable?

If you meant JTable, you want to write a TableCellRenderer.

You might want to read the chapter in a Swing book on these beasts.

The crucial fact to keep in mind is that the default JLabel component
you render is the same for all cells, so any changes you make to it
will reflected in all other cells. In other words, set ALL the
attributes you change for any cell.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top