Check out example codes for "jlabel on the center of a jpanel". It will help you in understanding the concepts better.

Code Example 1

panel.setLayout(new GridBagLayout());
panel.add(label);

Learn ReactJs, React Native from akashmittal.com