I’m building a GUI with several JPanels and with a BoxLayout with Y-axis. I also use borders with titles around the JPanels. I wonder if it’s possible to control the space between the border of the JPanel and the window frame? I’m also wondering if it’s possible to justify the content inside the JPanels to the left or right? Thanks!
Share
You could add an
EmptyBorderusingCompoundBorderto wrap both, the current border and the emtpy one. The empty border would not be rendered but allow you to define the margin to the frame using insets.The justification of the panel’s content would depend on the layout manager used there. Do you have a
BoxLayoutinside the panel as well?Edit:
A really good and easy to use layout manager is MigLayout. It allows defining custom insets, alignment etc. inline and using just a single layoutmanager.