I am learning AWT. I have add a panel inside frame. I have set bounds to the panel such that it stays at the bottom. But when I maximize or minimize, the panel is reset to the center top. Is this a normal behavior? Is there any events for minimize or maximize?
-
What layout manager are you using? – otoomey May 07 '17 at 19:21
-
*"I have set bounds to the panel such that it stays at the bottom."* Don't use bounds, use the `BorderLayout.PAGE_END` layout constraint. Java GUIs have to work on different OS', screen size, screen resolution etc. using different PLAFs in different locales. As such, they are not conducive to pixel perfect layout. Instead use layout managers, or [combinations of them](http://stackoverflow.com/a/5630271/418556) along with layout padding and borders for [white space](http://stackoverflow.com/a/17874718/418556). – Andrew Thompson May 08 '17 at 03:27
1 Answers
I am learning AWT.
Why? It was replaced by Swing a decade ago. Some people would even argue the Swing has been replaced by JavaFX.
In any case you were given a link in you last question (that you have now deleted) to the Swing tutorial. Why have you not read the tutorial?
The basic concepts of Swing and AWT are the same, since Swing is built on top of AWT, so by reading the Swing tutorial you will learn many of the AWT concepts. In most cases the difference it the component class name.
the panel is reset to the center top. Is this a normal behavior?
Yes, Swing (and AWT) work with layout managers. The layout manager is responsible for determining the size and location of a component. Don't try to manually set the size or location of a component.
Is there any events for minimize or maximize?
Yes, you can use a WindowListener
.
Read the Swing tutorial. You will find sections on:
- Using Layout Managers
- How to Write a WindowListener

- 321,443
- 19
- 166
- 288