KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
just (astonishingly ;-) noticed the reason why apps look so cramped on my win6+ machines (same for Vista and Win7, both with 120dpi setting, jdk6 and jdk7): the control font looked up from the the desktop property has both the wrong font family and the wrong size: public static void main(String[] args) { Font guiFont = (Font) Toolkit.getDefaultToolkit().getDesktopProperty("win.defaultGUI.font"); int guiSize = guiFont.getSize(); Font iconFont = (Font) Toolkit.getDefaultToolkit().getDesktopProperty("win.icon.font"); System.out.println("gui default: " + guiFont + "\nicon default: " + iconFont); } output: gui default: java.awt.Font[family=Tahoma,name=Tahoma,style=plain,size=13] icon default: java.awt.Font[family=Segoe UI,name=Segoe UI,style=plain,size=15] The latter is used in native applications for nearly all text, while Swing uses the former ... Questions: Could there be any reason for this, or just a bug? Who's responsible: the Swing lookup (when reading-in the desktopProperty from relevant system resources) or the OS in not reporting it correctly? How to force the usage of the latter? Options for solving the last: With full control about the LAF one might consider to set all relevant text fonts (that's what JGoodies does, factored into a FontPolicy/Set). A dirty hack is to set the value of the defaultGUI desktop property to the correct value - it involves reflective access to the toolkit, which naturally will blow in security constrained contexts. ?? Edit Just in case anybody is interested, here's the dirty hack: /** * Replaces the default gui desktop font property with the icon font * if the former is smaller. * */ public static void ensureDefaultGUIFontSize() { Toolkit toolkit = Toolkit.getDefaultToolkit(); Font guiFont =
Tags (comma-separated)
Save Edits
Cancel