Re: Automatically resize font when component size changes?




<larkmore@xxxxxxx> wrote in message
news:1174397161.494761.84730@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Well, I'm trying to write this to be flexible so I can reuse the code
in the future for other things, like generic title bars, etc. I'm
still stumped on how to find the area to paint, but you might be onto
something with the custom override of paint(). Then I can guarantee
alignment and not worry about getting truncated to "..."

Also, if the font has numbers with different widths (which seems
fairly rare) you still need to paint each number at a fixed position.
You don't want the numbers jumping around when the time changes
the way they would on a JLabel with such a font.

The only
killer like I said was that I'm trying to make this reusable so on a
modern 3Ghz processor it won't really matter, but trying to scale it
to some of the less powerful CPUs found on single board computers or
embedded devices could get messy. But, it is what it is. Thanks
again!

A search for the best font size will take minimal time. You
could optimize that with an initial guess based on the panel
size, followed by something like a proportional search, but
I think you'll find that a simple linear search will be plenty
fast.


.



Relevant Pages

  • Re: Does anyone know how to blur a font to make it barely legible?
    ... If you aren't using a font that looks blurred, ... paste multiple copies into Paint and slightly offset each ... >> Jay Freedman ... >> newsgroup so all may benefit. ...
    (microsoft.public.word.docmanagement)
  • Re: Fonts, Part 2
    ... Create your page or portion of the page with the font you want. ... Then open Paint, click Edit, select Paste and an image of the page will appear ... When you have the area you want in the Cut box, click Edit and select Cut. ...
    (microsoft.public.frontpage.client)
  • Re: Make font size to fit screen
    ... I don't think you want to compute the font size in the paint() call. ... compute all of the metrics needed for painting, ... Why recompute the metrics on every repaint? ...
    (comp.lang.java.gui)
  • Problems Measuring Font Height
    ... I am trying to figure out how high a particular font will paint. ... using Courier and Courier New fonts and have recently found some problems ... The problem is that I paint the text with OPAQUE background mode (I do not ...
    (microsoft.public.win32.programmer.gdi)
  • Font changed in Windows Programs
    ... I am running XP Home SP2 and have noted that in WordPad and Paint the font ...
    (microsoft.public.windowsxp.general)