Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1240

Re: Automatically resize

From "larkmore" <larkmore@THRWHITE.remove-dii-this>
Subject Re: Automatically resize
Message-ID <1174393441.687014.66540@n59g2000hsh.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
References <1174345145.079498.37550@l75g2000hse.googlegroups.com>
Date 2011-04-27 15:32 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
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

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Automatically resize font "larkmore" <larkmore@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
  Re: Automatically resize "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
    Re: Automatically resize "larkmore" <larkmore@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
      Re: Automatically resize "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
        Re: Automatically resize "larkmore" <larkmore@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
          Re: Automatically resize "Larry Barowski" <larry.barowski@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
      Re: Automatically resize "bcd" <bcd@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
        Re: Automatically resize "John W. Kennedy" <john.w..kennedy@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000

csiph-web