We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Is there a way to make items bold in a JList using a DefaultListModel?

Suppai
Suppai asked
on
Medium Priority
532 Views
Last Modified: 2013-11-23
Is there a way to make items bold in a JList using a DefaultListModel? If there is, how is it done?
Comment
Watch Question

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
You use a custom cell renderer for that
Suns swing tutorial shows how to set one up
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
The objects in your model will need some property to indicate whether to bold or not
Java Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
another example here

http://www.java2s.com/Tutorial/Java/0240__Swing/CreatingaComplexListCellRendererfonticonandcolor.htm

the bold bit is easy. What you need to think about is what property of the beans in your list are used to indicate whether it should be bold or not.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
ksivananthVice President
Commented:
if you want to make that as the default for any JList, you can do through UIManager, have the below code in your main

UIManager.put("List.font", new FontUIResource( yourFontHere ));
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.