The default font used for menues, buttons etc. in the Metal look and
feel is a bold serif kind of font, which looks really ugly. This is not
fault of Squirrel but that of the Metal L&F theme.
(You get the Metal L&F as default when running a Swing app on Linux or
other Unix'es).
It is quite easy to top level change that font into a more reasonable
"standard" font. Below is a function which does the job!
The function must be called in the program initialization fase sometimes
before the instantiation of the first window (Code snippet to handle
this shown further down).
// Change all font resources into using a non bold sans serif font
// with user specified font size!
public static void setFont(int fontSize) {
Font defaultFont= new Font("SansSerif", Font.PLAIN, fontSize);
for(Enumeration i=UIManager.getDefaults().keys();
i.hasMoreElements();)
{
Object key= i.nextElement();
if(UIManager.get(key) instanceof FontUIResource) {
UIManager.put(key, new FontUIResource(defaultFont));
}
}
}
Example of an application main, which I use for most swing apps
public static void main(String[] args)
{
try
{
// Set look and feel to the system default.
// On systems where default is "Metal", replace the default font
String uiClassName = UIManager.getSystemLookAndFeelClassName();
if(uiClassName.endsWith("MetalLookAndFeel")) {
setFont(12);
}
UIManager.setLookAndFeel(uiClassName);
}
catch(Exception e)
{
e.printStackTrace();
}
new App();
}
NOTE: I'm not an active Squirrel developer so I don't have source update
access. I would be happy if the maintainer could apply the code!
/Kim
|