Optimal measurement of java gui

what will be the standard / optimal size of java swing gui (e.g. JFrame) when rendering on user screen?
would it be wise to set a preferred size of 1024 x 768 or 800 x600 or something like that?
should we set the preferred size according to the screen size? or is this not a good route?

+4
source share
4 answers

In my experience, it is usually better not to set preferred sizes, but it’s wise to use layout managers and call pack() in the top-level window after adding all the components, allowing the layout and layout managers themselves.

+3
source

This is not a Java issue, but a user interface design issue. The application that I am currently developing requires at least 1024 by 768 to meet all the requirements. But if it does not need space, then why start with this size? Why not let the user maximize the window if he wants to? The user interface should work as many different sizes of the display as possible.

My policy is that the best window size is the smallest, which still allows the user to do everything he needs to work with the program. Now back to Java: when creating the swing application, call pack () after placing all the components in the containers. If for some reason I feel the package is too tight, then I can add a little to the width or height immediately after calling the package.

If you need to know the dimensions of the display you are working on, use this:

  Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screensize = toolkit.getScreenSize(); 

With swing, you can also set the preferred size for the components, and this will affect the size that they occupy after calling pack ().

+1
source

Large enough for all components to be in a JFrame and no more. As a rule, I do not set the frame size in pixels and just let the components frame size so that I know that everything will fit.

I would say that it is safe to accept resolutions over 1024x768 , but that depends on how compatible your application is. To be sure, you can get the screen size using Toolkit.getDefaultToolkit().getScreenSize();

0
source

According to statistics provided by w3schools here: http://www.w3schools.com/browsers/browsers_display.asp , it can be assumed that people have a screen resolution of 1024x768 or more.

If you are creating a fixed-size GUI, I would recommend staying a bit under this resolution to accommodate users with a double-height taskbar or side taskbar (try to make sure yourself that something works, for example, 900x700).

If your window resizes, I would try different sizes to see what looks better. Depending on the layout of your application, too small will look too busy, too large can make visual elements too meager. Obviously, you should not exceed the fixed size limit above or the current resolution.

You can also try to run the full-screen mode of the application, this only makes sense for some applications.

0
source

Source: https://habr.com/ru/post/1396728/


All Articles