Check out example codes for "separateur JMenu swing java". It will help you in understanding the concepts better.

Code Example 1

12345 
JMenu jm1 = new JMenu("Ouvrir ou Fermer");
JMenuItem jm11 = new JMenuItem("Ouvrir");
jm1.addSeparator();
JMenuItem jm12 = new JMenuItem("Fermer");

Learn ReactJs, React Native from akashmittal.com