Apologies in advance if I'm not using the correct words/names/terminologies.
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: I haven't written any code so far. It was all made with that JFrame
design thingy
from NetBeans
.
There's no easy way to accomplish this and I would question why you think it's required, however...
While I'm sure there is probably an easy way to achieve this, most of the solutions I looked into required some kind of
Graphics
context and when I thought about variable width fonts, it quickly became a real mess...You could use something like...
I did consider using
Font#deriveFont(AffineTransform)
, but this would require me to have some context as to the original size of the component/textSince 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.
Like this:
in formComponentResized.