Problem with component position and size

Asked

Viewed 827 times

3

I’m doing a program using the wizard, the famous "click and drag". Most of the project I’m doing on my computer, and I use the command to maximize the screen on the frame, and I adjust the panels so that everything fits, but when I continue the project on the computer of my service for example, the size changes completely and keeps cutting as if it did not fit on the screen.

Essa é a tela que fica no computador do serviço

essa é a tela que fica no meu notebook

I wonder if there is any way to standardize this, independent of the computer, make the screen open in full screen and fit according to the desktop.

  • which IDE is using to mount the screens?

  • Netbeans IDE V8.2

  • Yes you can standardize, provide a [mcve] to help you.

2 answers

3

If you want to define the sizes in a relative way, so that the positions are respected independent of the screen, you need to use the layouts. They serve as component organizers on the screen or within other components on the screen itself. With this, you will always have the same organization regardless of the screen resolution of the user running the application.

How to maintain the size of the JFrame relative to user screen size, in this answer there is a solution that can work.

How did you not introduce a Minimum, Complete and Verifiable Example, you can not suggest anything specific to the screen presented, but the solution for sure is the use of one or more managers.

Just to demonstrate the power of layout managers, along with the hint of the linked response, see the example below where I made a screen with proportions relative to half of my screen, and even resizing, the components do not disorganize, only the table adapts thanks to the JScrollPane.:

inserir a descrição da imagem aqui

The netbeans wizard may seem tempting, but using it without knowing the swing API and its workings will plaster you into this IDE and trap you into problems like the one you face in this question. I suggest that, before playing drag and drop, learn the basics about swing and its components, as it is essential to have a sense of how to create screens and organize components without relying on Ides, as much as the netbeans screen builder or windowbuilder in eclipse makes this process quite easy.

-3

Make a window with fewer pixels than when increasing windows itself fixes. but if the window is too big he can not do this not to lose information.

You used the click and drag to your computer’s options, but you need to make a smaller pattern to fit on all possible screens. try to set your monitor at the time of clicking and dragging to 1024x768 for example. is a bad resolution but will fit on any computer. After you return to normal size the screen will get better.

But the right is not to use the click and drag even haha

  • No percentage definitions in drag and drop mode?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.