How can I add a vertical separator in the pop up menu of the app in the task bar ?
tray = SystemTray.getSystemTray();
openMenuItem = new MenuItem("Open P");
stopKLMenuItem = new MenuItem("Stop");
exitMenuItem = new MenuItem("exit");
menu.add(exitMenuItem);
menu.add(stopKLMenuItem);
menu.addSeparator(); // adds a horizontal separator
menu.add(openMenuItem);
trayIcon = new TrayIcon(image,"P",menu);
The statement menu.addSeparator()
adds a horizontal separator. I also wanted a vertical separator like :
How do I do this ?
One easy trick is to add an empty icon to the JMenuItem. The look and feel then adds the vertical separator you are looking for (of course, this only works with the Windows L&F, other L&F may render this differently):
And the code that produced it: