I have a JPanel, on it are added an image and label, in that order.
It is very unlikely that more will be added to the panel.
The default formatting looks fine when it’s displayed, in spite of me not using a Layout Manager.
Is it best practice to have them laid out by a LM anyway to be safe for future development, or is it not worth the extra dev time making it look essentially the same?
If you create a
JPanelusing the default constructor the panel will use aFlowLayout. If you’re happy with the results of using this layout manager then by all means don’t change anything.If however you wish to explicitly not use a layout manager you need to set the layout to
null; e.g.This isn’t recommended as the results are then highly dependent on the particular Look & Feel used. More information here.