简体   繁体   English

无法更改java.awt.MenuBar中的字体

[英]Unable to change font in java.awt.MenuBar

I'm trying to change the font in an AWT menu bar using MenuBar.setFont() . 我正在尝试使用MenuBar.setFont()更改AWT菜单栏中的字体。 The call works for the menu bar's child menus, but the menu bar itself doesn't change font (I'm trying to make the font larger). 该调用适用于菜单栏的子菜单,但是菜单栏本身不会更改字体(我正在尝试放大字体)。

Does anyone know whether this is possible to do? 有人知道这是否可能吗?

I'm using JRE 1.6 on Windows XP. 我在Windows XP上使用JRE 1.6。

Update : Changing the font does seem to work so long as the text fits within the menu bar height, otherwise the font size is reduced. 更新 :只要文本适合菜单栏的高度,更改字体似乎确实可行,否则字体大小会减小。

Use Swing. 使用Swing。 I don't think that AWT is capable of restyling native component peers in a reliable fashion. 我不认为AWT能够以可靠的方式重新设计本地组件的同级对象。 I know for certain that SWT can't, and it's a far more sophisticated toolkit than AWT. 我肯定知道SWT无法做到,并且它是比AWT更复杂的工具包。 This is part of why it was essentially deprecated (in favor of Swing) back in Java 1.2. 这就是为什么在Java 1.2中不推荐使用它(支持Swing)的部分原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM