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


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

Re: Scaling java app

From Knute Johnson <nospam@rabbitbrush.frazmtn.com>
Newsgroups comp.lang.java.programmer
Subject Re: Scaling java app
Date 2016-11-21 18:23 -0600
Organization A noiseless patient Spider
Message-ID <o1035n$n3d$1@dont-email.me> (permalink)
References <o0v9ih$j1e$1@dont-email.me> <o0vj3b$s5n$1@dont-email.me> <3b705f92-d63a-4062-a7e3-72bf4ac279bc@googlegroups.com>

Show all headers | View raw


The Windows look and feel will do some scaling of the frame and other 
bits.  To get this to just work it looks like I'm going to have to 
change it from a Swing app to a JavaFX app where that sort of scaling is 
automatic.

Thanks for all the suggestions everybody (Stefan too).  The temporary 
workaround is to use the windows look and feel and scale the font based 
on screen size.

knute...

On 11/21/2016 2:33 PM, Eric Douglas wrote:
> On Monday, November 21, 2016 at 2:49:45 PM UTC-5, Martin Gregorie wrote:
>> I express the required width and height of all GUI components as a
>> percentage of the screen size, which is retrieved by using ToolKit, and
>> calculate the required size (screenSize.width * required width,
>> screenSize.height, requiredheight) when the component is created. This
>> way the the main window, for instance, will always be, say, 90% of the
>> screen height and 95% of its width and the components will always occupy
>> the same amount of the main window. The same trick also works for scaling
>> fonts.
>>
>> It gets actual workouts too, since the same apps run on my development
>> box, which uses a 1024x768 screen and on this laptop with a 1280x800
>> screen. Here's code showing how I get the screen dimensions:
>>
>> import java.awt.*;
>> import javax.swing.*;
>>
>> public class GetScreenSize extends JFrame implements Runnable
>> {
>>    Toolkit        toolkit = null;
>>    Dimension      d = null;
>>
>>    public static void main(String args[])
>>    {
>>       GetScreenSize gss = new GetScreenSize();
>>       EventQueue.invokeLater(gss);
>>    }
>>
>>    public void run()
>>    {
>>       toolkit = getToolkit();
>>       d = toolkit.getScreenSize();
>>       System.out.println("Screen width = " + d.getWidth());
>>       System.out.println("Screen height = " + d.getHeight());
>>    }
>> }
>
> I just set my windows to hard coded sizes, currently no bigger than 1024x600, the minimum resolution to run the app.  You could scale them but then you should provide an option for that.  What if I have a smaller screen with a higher resolution, what if I still want the higher resolution to make the app windows smaller, or what if I want them fit to the screen?  What if I use a 55" screen, then maybe I want them fit to the screen for presentation, or maybe I want to show 4 windows at once.
>
> For my app we find it easier to use non-re-sizable windows, but the simplest option for the end user may be to make the window re-sizable.  Every component can be linked to the window to resize itself if the user resizes the window.  Then either the LayoutManager adjusts their location, or they also have to move themselves if the component above them changes it's size and/or location.  I have a demo program with a JTable that populates with different column widths and adjusts it's total size, and a JLabel displaying the total rows populated linked to the bottom right corner of the table with a ComponentListener (null layout).
>

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


Thread

Scaling java app Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-11-21 11:06 -0600
  Re: Scaling java app Martin Gregorie <martin@address-in-sig.invalid> - 2016-11-21 19:48 +0000
    Re: Scaling java app Eric Douglas <e.d.programmer@gmail.com> - 2016-11-21 12:33 -0800
      Re: Scaling java app Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-11-21 18:23 -0600
        Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-21 21:22 -0500
          Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-21 21:25 -0500
            Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-21 22:29 -0500
              Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-21 22:41 -0500
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-22 10:51 -0500
          Re: Scaling java app a.laforgia@gmail.com - 2016-11-23 04:58 -0800
            Re: Scaling java app Eric Douglas <e.d.programmer@gmail.com> - 2016-11-23 05:18 -0800
              Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-23 09:52 -0500
                Re: Scaling java app Eric Douglas <e.d.programmer@gmail.com> - 2016-11-23 07:51 -0800
            Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-23 09:46 -0500
              Re: Scaling java app Eric Douglas <e.d.programmer@gmail.com> - 2016-11-23 08:07 -0800
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-23 12:10 -0500
                Re: Scaling java app Eric Douglas <e.d.programmer@gmail.com> - 2016-11-23 10:39 -0800
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-23 14:57 -0500
            Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-23 15:04 -0500
              Re: Scaling java app a.laforgia@gmail.com - 2016-11-24 02:01 -0800
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-24 09:10 -0500
                Re: Scaling java app a.laforgia@gmail.com - 2016-11-25 03:48 -0800
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-25 09:58 -0500
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-25 10:22 -0500
              Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-25 10:34 -0500
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-26 00:01 -0500
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-26 09:05 -0500
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-26 09:52 -0500
  Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-21 19:46 -0500
    Re: Scaling java app Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-11-21 21:12 -0600
      Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-21 22:44 -0500
        Re: Scaling java app Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-11-22 09:56 -0600
          Re: Scaling java app Silvio <silvio@internet.com> - 2016-11-22 20:07 +0100
            Re: Scaling java app Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-11-22 18:00 -0600
              Re: Scaling java app Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-11-22 19:35 -0600
              Re: Scaling java app Silvio <silvio@internet.com> - 2016-11-24 00:51 +0100
          Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-23 10:26 -0500
            Re: Scaling java app Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-11-23 15:54 -0500
              Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-23 20:46 -0500
          Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-23 12:00 -0500
            Re: Scaling java app Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-11-23 19:53 -0600
              Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-23 21:21 -0500
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-23 21:34 -0500
                Re: Scaling java app Eric Douglas <e.d.programmer@gmail.com> - 2016-11-28 05:06 -0800
                Re: Scaling java app Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2016-11-24 20:45 +0800
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-24 09:12 -0500
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-25 10:32 -0500
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-26 00:05 -0500
                Re: Scaling java app Martin Gregorie <martin@address-in-sig.invalid> - 2016-11-26 15:24 +0000
                Re: Scaling java app Eric Douglas <e.d.programmer@gmail.com> - 2016-11-28 05:08 -0800
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-28 19:51 -0500
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-28 21:18 -0500
                Re: Scaling java app lewbloch@gmail.com - 2016-11-29 13:50 -0800
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-29 16:53 -0500
                Re: Scaling java app lewbloch@gmail.com - 2016-12-01 13:27 -0800
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-01 16:45 -0500
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-12-01 22:07 -0500
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-02 10:35 -0500
                Re: Scaling java app Gene Wirchenko <genew@telus.net> - 2016-12-02 08:53 -0800
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-02 15:05 -0500
                Re: Scaling java app Martin Gregorie <martin@address-in-sig.invalid> - 2016-12-02 20:25 +0000
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-02 16:20 -0500
                Re: Scaling java app Martin Gregorie <martin@address-in-sig.invalid> - 2016-12-02 18:33 +0000
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-02 15:16 -0500
                Re: Scaling java app Martin Gregorie <martin@address-in-sig.invalid> - 2016-12-02 22:57 +0000
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-02 19:25 -0500
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-12-02 22:18 -0500
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-02 22:28 -0500
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-12-02 22:36 -0500
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-03 11:27 -0500
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-12-02 22:05 -0500
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-02 22:30 -0500
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-12-02 22:41 -0500
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-03 11:29 -0500
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-12-02 22:00 -0500
                Re: Scaling java app lewbloch@gmail.com - 2016-12-02 11:40 -0800
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-02 15:17 -0500
                Re: Scaling java app lewbloch@gmail.com - 2016-12-02 16:26 -0800
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-02 20:46 -0500
                Re: Scaling java app Eric Douglas <e.d.programmer@gmail.com> - 2016-12-02 12:44 -0800
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-12-02 21:57 -0500
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-02 22:40 -0500
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-12-02 22:51 -0500
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-03 11:42 -0500
                Re: Scaling java app Andreas Leitgeb <avl@logic.at> - 2016-12-02 15:43 +0000
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-12-02 21:19 -0500
                Re: Scaling java app Martin Gregorie <martin@address-in-sig.invalid> - 2016-12-02 10:28 +0000
                Re: Scaling java app Jerry Stuckle <jstucklex@attglobal.net> - 2016-12-02 10:37 -0500
                Re: Scaling java app Gene Wirchenko <genew@telus.net> - 2016-12-02 09:00 -0800
                Re: Scaling java app Eric Douglas <e.d.programmer@gmail.com> - 2016-12-01 13:50 -0800
                Re: Scaling java app Arne Vajhøj <arne@vajhoej.dk> - 2016-11-25 10:30 -0500
  Re: Scaling java app Roedy Green <inquiry@mindprod.com> - 2016-11-27 16:42 -0800

csiph-web