Sunday 15 March 2015

java - What happens when a JFrame is resized? -


I know what really happens in Java when JFrame resizes.

I am asking for this because I am due to a problem by adding one component inside my big container (the type of JPNL) to Jeffram. I want to add something when the user performs a certain task, but the component Jefframe is changed in some way, unless it is explicitly added.

I showed it when I was trying to get new component to show; As a secondary question I called myJFrame.pack (), I would like to know what the pack () does, both are generally more specific to resize and the java documentation makes it sound as if it is every component Will change to the preferred size. My solution, if I decide to use pack () in my implementation to display new components, then always have to set the preferred size. Can someone authenticate it for acceptable programming practice? It seems like a good idea.

I also tried to paint again to show the new component, but it does not work.

You can add to the container () and then Re-color () needs to be called which receives added or deleted components during the runtime.

Modified () The layout of the container asks the manager to take those components again, and this is your code. Without this request, the layout does not change, and you do not see the changes until you change the size of the GUI, which works very much the same.

Note that if you are adding components to the GUI on start-up, then the solution pack () and setVisible (true) To call the top-level container, call to call all the components have been added.

Describe what the pack () does, all we do - read the source code.

No comments:

Post a Comment