Re: Automatically resize font when component size changes?
- From: larkmore@xxxxxxx
- Date: 20 Mar 2007 05:24:01 -0700
Thanks Andrew, but I kind of hoping there would be something a little
simpler. I've already looked at the FontMetrics as described in my
first post. If I use that, I would have to:
1) Figure out which string is the widest and tallest of all possible
strings. I'm betting it's likely 88:88:88 but to be safe, I'd have to
check all of them for a given font. Some weird font might make
11:11:11 really wide.
2) Figure out how much painting area I actually have within a JLabel.
Actually, I still don't know how to find this part out! I guess I
could just be conservative and say (width-16)x(height-16).
3) Figure out how large I could make the biggest string found in step
1 such that it would not overflow the dimensions found in step two.
Other than an experimental trial and error of create the string,
measure the string, compare against dimensions, repeat, I'm not sure
how to do this.
What I'm looking for is a way to drastically speed up this process so
I have the user resize the control on the fly without tanking the CPU.
-Will
.
- Follow-Ups:
- Re: Automatically resize font when component size changes?
- From: Bent C Dalager
- Re: Automatically resize font when component size changes?
- From: Andrew Thompson
- Re: Automatically resize font when component size changes?
- References:
- Automatically resize font when component size changes?
- From: larkmore
- Re: Automatically resize font when component size changes?
- From: Andrew Thompson
- Automatically resize font when component size changes?
- Prev by Date: Re: MacOS X: annoying rectangle during drag and drop
- Next by Date: Re: Automatically resize font when component size changes?
- Previous by thread: Re: Automatically resize font when component size changes?
- Next by thread: Re: Automatically resize font when component size changes?
- Index(es):
Relevant Pages
|