How to change Font Type of the Title Text of a JFrame?

Hi,I want to set a different Font Type for the Title text of the titlebar of my JFrame.Is it possible? Can anyone show me how if it is?Thanks.Niteen
[183 byte] By [niteenhatlea] at [2007-10-3 3:48:46]
# 1

if you don't have the 'Tall Paul' font, change to another

import javax.swing.*;

import java.awt.*;

class Testing

{

public Testing()

{

JFrame.setDefaultLookAndFeelDecorated(true);

JFrame f = new JFrame("Hello World");

f.getLayeredPane().getComponent(1).setFont(new Font("Tall Paul",Font.ITALIC,24));

f.setSize(300,100);

f.setLocation(400,200);

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

f.setVisible(true);

}

public static void main(String[] args){new Testing();}

}

Michael_Dunna at 2007-7-14 21:45:48 > top of Java-index,Desktop,Core GUI APIs...
# 2

Michael,

Thanks. It works!

But there was a problem. I was not using the :-

JFrame.setDefaultLookAndFeelDecorated(true);

so I have to use it now.

Is it possible to do it without the default decorated look and feel? Because the default LNF title bar has too much height and I am cramped for space.

I know that's no excuse. I tried but it doesn't work.. I am using a extended JFrame like this:-

class Testing extends JFrame

{

public Testing()

{

setSize(300,100);

setLocation(400,200);

Container container = getContentPane();

/* add components to this container here */

setVisible(true);

}

}

When I use getComponent() for the container, I get an ArrayIndexOutOfBound Exception.

When I set the argument to getComponent(0), the font in the title bar is not changed.

What else should I do?

Thanks.

Niteen.

niteenhatlea at 2007-7-14 21:45:49 > top of Java-index,Desktop,Core GUI APIs...
# 3
as far as I know, it can't be done the same way with a normal title barthe size in the posted example was largely to do with the 24 in this linenew Font("Tall Paul",Font.ITALIC,24)change to 8 or 10, see if the size is now acceptable
Michael_Dunna at 2007-7-14 21:45:49 > top of Java-index,Desktop,Core GUI APIs...
# 4
Yeah Michael,That helped!You can't have everything.Thanks again.Niteen.
niteenhatlea at 2007-7-14 21:45:49 > top of Java-index,Desktop,Core GUI APIs...
# 5
Hi,I tried to apply this solution to change the font of a JFrame title bar.But it doesnt seem to wotk with the Windows Look and feel.Can you help me here?Thanx
Priestexa at 2007-7-14 21:45:49 > top of Java-index,Desktop,Core GUI APIs...