简体   繁体   English

如何在 JAVA swing 中调整文本工具提示的大小

[英]How to Resize a Text Tool Tip in JAVA swing

我正在做一个小项目,我想让用户知道一些使用工具提示输入数据的信息,但文本工具提示大小太小,不是最好的视图,所以我想知道是否有人可以帮助我拿出来。

If you just want to resize your tooltip, you can probably call setPreferredSize(Dimension preferredSize) .如果您只想调整工具提示的大小,您可以调用setPreferredSize(Dimension preferredSize) You can set the dimension like so:您可以像这样设置尺寸:

Dimension d = myToolTip.getPreferredSize();
// Or:
Dimension d2 = new Dimension(20, 30);
myToolTip.setPreferredSize(d2);

EDIT: If you want to adjust the font of the text of the tooltip you can do so like this:编辑:如果你想调整工具提示文本的字体,你可以这样做:

UIManager.put("ToolTip.font", new Font("Arial", Font.BOLD, 14));

See here for the javadoc, here for an example, here for another SO question, and here for JToolTip customization.请参阅此处获取 javadoc,此处获取示例, 此处获取另一个 SO 问题, 此处获取 JToolTip 自定义。

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

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