根据按钮/标签大小调整文本大小 [英] Text resize according to button/label size
问题描述
如果我使用的单词/名称/术语不正确,请提前道歉.
Apologies in advance if I'm not using the correct words/names/terminologies.
我正在使用NetBeans
上的Swing创建我的GUI.由于布局的原因,我能够根据窗口大小使所有按钮和标签拉伸/缩小.但是,按钮/标签的文本大小完全不变.
如何根据按钮/标签的大小缩放文本大小?
I'm using Swing on NetBeans
to create my gui. I was able to make all the buttons and labels stretch/shrink according to the window size thanks to layouts. However the text size of the buttons/labels don't change at all.
How do I make the text size scale according to the buttons/labels size?
PS:到目前为止,我还没有编写任何代码.都是由NetBeans
中的JFrame
设计thingy
制成的.
PS: I haven't written any code so far. It was all made with that JFrame
design thingy
from NetBeans
.
推荐答案
由于这是一个简单的程序,因此它不必尽可能地高效,所以我最终使用了此处给出的答案,由于某种原因,删除.
Since this is a simple program it doesn't need to be as most efficient possible so I end up using an answer posted here that, for some reason, was deleted.
赞:
button.setFont(button.getFont().deriveFont((float)(button.getWidth()/2)));
处于formComponentResized.
in formComponentResized.
这篇关于根据按钮/标签大小调整文本大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!