This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Font  RSS feed

 
Jeff Smith
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I go about changing the Font for all JList's without having to go through and set the font for each one? I just download java 1.4 and for whatever reason they decided to make the default font for JList's bold, which makes it really difficult to read. The problem I'm having is that I want the JList that displays files in a JFileChooser to not have bold font, but can't directly access that component.
Please Help!
Jeff
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could create your own extend JList and use whatever Font you want. That way all of yours will be the same.
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This one is easy. Use javax.swing.UIManager.put() to create a user default property to map the font of all ListUI delegates to the Font you supply.
The only hard part is sometimes finding the name of the property to use. I don't know where this is "officially" documented; I always just look at the source code for one of the look & feels to double-check the property name.
Looking at javax.swing.plaf.basic.BasicLookAndFeel, here are some List-related properties.

So if you wanted to use 12 point Arial italic,
Font myListFont = new Font ("Arial, Font.ITALIC,12);
UIManager.put("List.font",myListFont);

You need to make the call before you display any JLists,like at the beginning of your program.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!