How to resize the application with the monitor?

Asked

Viewed 765 times

1

I have an app that opens a JFrame, having at the top a JMenuBar.

Until I call an item from Menubar one JTabbedPane, is hidden and as soon as a menu item is chosen, a Tabbed with jPanel inside opens.

In this jPanel I have several components such as buttons, textfield, jspinner, jlabel, etc.

It happens that I made the application programming on my pc and, when putting in network for other pcs, the same opens not occupying the screen of the other monitors, for a matter of resolution and screen sizes. It is worth saying that only Jpnael does not open the screen size.

How can I solve this proportionally? So that no component is out of place. Sort of percentage?

1 answer

5

To make the application open maximized, simply add the next snippet before the setVisible():

seuFrame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);

And so that the JPanel fit into the JFrame:

seuFrame.setContentPane(seuJPanel);

Remembering that if you have several panels inside the Frame, you need to create one to be the main one, which will contain all of them.

However, in order for the components to fit according to resolution, you need to work with Layout Managers, they are responsible for the distribution of components within a Container any, just choose the one that best meets your need, or merge several together.

  • Thank you, diegofm. I will try here to adapt your idea. As soon as I finish this post here.

Browser other questions tagged

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