Font - createFont & drawString

I'm trying to load a TrueType Font & use that font in a TitleBorder and various other places (sometimes in AWT or Swing components, sometimes just by calling drawString).

I'm able to load the Font successfully but it is not being painted successfully. In other words, the font that is being drawn is NOT the font that I created.

Is there a problem with using Fonts and calling drawString on that Font? Even when using that Font with Swing components?

TITLE_FONT = Font.createFont(Font.TRUETYPE_FONT,new File("KABELN.TTF"));

LineBorder lineBorder = new LineBorder(TITLE_COLOR);

TitledBorder titleBorder = BorderFactory.createTitledBorder(

lineBorder,"My Title",TitledBorder.LEFT, TitledBorder.ABOVE_TOP,

TITLE_FONT, TITLE_COLOR);

ARG! It is not using the Kabel font for the title of my border

I'm using 1.5.0_04-b05

Any ideas? Thanks

[907 byte] By [matt_apta] at [2007-10-3 8:16:25]
# 1

// Before you create any titled borders, you can see the default

// font that Swing will use

Font font = UIManager.getFont("TitledBorder.font");

// and set the font you want to use instead. Wrapping it in a

// UIResource makes it available/usable to/by any LookAndFeel.

FontUIResource resource = new FontUIResource(TITLE_FONT);

UIManager.put("TitledBorder.font", resource);

crwooda at 2007-7-15 3:21:34 > top of Java-index,Desktop,Core GUI APIs...
# 2

Thanks, that worked.

Also, I realized that what I had been doing SHOULD have worked. The code that I posted to this forum actually would have worked too (but in the actual code that was being used there was a problem with a local variable having the same name as a static member variable of my class resulting in the desired font not *really* being used for the TitledBorder)

matt_apta at 2007-7-15 3:21:34 > top of Java-index,Desktop,Core GUI APIs...