This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I am a swing newbie. I have some questions, 1. I would like to know is it possible to set font on JPanel and make the font applicable to all components on the JPanel like JTextBox, JLabel... I tried setting font on individual components, it worked but when set on JPanel, it didn't work.
2. What is the most widely used font in Swing Applications when delivering the product to customers.
3. What would happen if we tried to set a font and that font is missing/not installed in the users computer, will that result in null pointer exceptions?
1. I would like to know is it possible to set font on JPanel and make the font applicable to all components on the JPanel like JTextBox, JLabel... I tried setting font on individual components, it worked but when set on JPanel, it didn't work.
2. What is the most widely used font in Swing Applications when delivering the product to customers.
3. What would happen if we tried to set a font and that font is missing/not installed in the users computer, will that result in null pointer exceptions? [/QB]
1) JPanel is used as a container and as such does not have any text to display on its own. So setting the font for a JPanel doesn't have any effect. In case you are thinking, the font will be inherited by the children added to the panel, no it doesn't work that way
2) I usually set the LAF to the System LAF and don't worry about fonts at all. This is good usability. The user is presented with a UI with fonts and color schemes he is already used to.
3) Why don't you try it out yourself and let us know?
iterate the UIManager defaults, looking for fonts, and setting them to what you want
Kasi Viswan
Ranch Hand
Joined: Sep 27, 2008
Posts: 42
posted
0
Thanks Maneesh and Michael for your inputs, was helpful.
I want to set the font as Verdana, so i checked if Verdana is available in the system fonts, if yes, i will set that font otherwise will bypassing setting the custom font. It works.