I am building a java desktop app, but when maximize full screen component are not fit to screen. display some gaps. I am using eclipse, border layout for content panel and null for inside panel. What layout should I use ? I am adding a picture for better understanding.
Asked
Active
Viewed 32 times
-1
-
2use `BorderLayout` - (almost) never `null` - `null` means you must do all the layout (size, location, borders, ...) – user16320675 Jun 04 '22 at 10:56
-
Welcome to Stack Overflow. Please take the [tour] to learn how Stack Overflow works and read [ask] on how to improve the quality of your question. Then [edit] your question to include your source code as a working [mcve], which can be compiled and tested by others. Check https://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html for the different layout manager you can use, you can even combine them. – Progman Jun 04 '22 at 11:25
-
1*and null for inside panel.* - and that is your problem. You will never get dynamic resizing of components with a null layout **Don't use a null layout** Swing was designed to be used with layout manager exactly for the reason described here. Layout manager can give you dynamic resize when used properly. IN your case: 1) add the scroll pane to the `BorderLayout.CENTER`. 2) create a panel for the buttons. Add this panel to the `BorderLayout.PAGE_END`. – camickr Jun 04 '22 at 13:42
-
Try looking at [Making a component full screen](https://stackoverflow.com/questions/15164485/making-a-single-component-full-screen). – Alias Cartellano Jun 04 '22 at 17:04