Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 454
  • Last Modified:

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

Is there a way to make items bold in a JList using a DefaultListModel? If there is, how is it done?
0
Suppai
Asked:
Suppai
  • 3
  • 2
2 Solutions
 
objectsCommented:
You use a custom cell renderer for that
Suns swing tutorial shows how to set one up
0
 
objectsCommented:
The objects in your model will need some property to indicate whether to bold or not
0
 
ksivananthCommented:
0
 
objectsCommented:
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.

0
 
ksivananthCommented:
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 ));
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now