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


Groups > comp.lang.java.programmer > #36087

Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this?

From Martin Gregorie <martin@address-in-sig.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this?
Date 2016-12-12 12:08 +0000
Organization A noiseless patient Spider
Message-ID <o2m3vj$gpu$1@dont-email.me> (permalink)
References <75624c6e-6a78-4e8a-82a4-4ff2556cc241@googlegroups.com> <5bda0936-09ee-4eea-8001-e0ad17f31b0b@googlegroups.com> <o2f7a9$443$1@dont-email.me>

Show all headers | View raw


On Fri, 09 Dec 2016 21:22:17 +0000, Martin Gregorie wrote:

> When I've needed to do something like this, my outermost GUI container
> (a JPanel) has been sized to fit the screen (size expressed in pixels).
> All labels, Text areas, etc are auto-scaled to match by expressing their
> sizes as percentages of the outermost container and the font scaled to
> match: during initialisation I construct a font with that size and use
> it everywhere, the benefit being that I don't need to resize and fonts
> after the program has been initialised.
> 
> Modified Font construction is easy:
> 
> import java.awt.Font;
> 
> public class MyFont extends Font {
>    private int fontsize;    /* in pts */
> 
>    public EditFont(int fontsize)
>    {
>       super("Monospaced", PLAIN, fontsize);
>       this.fontsize = fontsize;
>    }
> }
> 
> ...and add any other methods you need in order to size a JLabel, etc, to
> contain a given string.

Faulty editing (my bad): replace EditFont with MyFont.


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? The Kreepy Gamer <tylerc2077@gmail.com> - 2016-12-06 15:21 -0800
  Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-12-07 13:36 -0600
  Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? The Kreepy Gamer <tylerc2077@gmail.com> - 2016-12-08 12:48 -0800
    Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-12-08 15:30 -0600
    Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? Martin Gregorie <martin@address-in-sig.invalid> - 2016-12-08 22:17 +0000
      Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? Arne Vajhøj <arne@vajhoej.dk> - 2016-12-08 20:09 -0500
      Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? Gene Wirchenko <genew@telus.net> - 2016-12-09 09:07 -0800
        Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? Martin Gregorie <martin@address-in-sig.invalid> - 2016-12-09 20:01 +0000
  Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? Nigel Wade <nmw@local.domain> - 2016-12-09 10:54 +0000
  Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? The Kreepy Gamer <tylerc2077@gmail.com> - 2016-12-09 11:35 -0800
    Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-12-09 15:32 -0500
    Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? Martin Gregorie <martin@address-in-sig.invalid> - 2016-12-09 21:22 +0000
      Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? Martin Gregorie <martin@address-in-sig.invalid> - 2016-12-12 12:08 +0000
    Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? Arne Vajhøj <arne@vajhoej.dk> - 2016-12-11 20:48 -0500
  Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? The Kreepy Gamer <tylerc2077@gmail.com> - 2016-12-12 11:18 -0800
    Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-12-12 14:22 -0500
    Re: When resizing text to fill a JLabel the text sometimes "jiggles", how do I fix this? Arne Vajhøj <arne@vajhoej.dk> - 2016-12-12 20:15 -0500

csiph-web