I have a problem when i want insert a separator with JSeparator for Java Swing application. In point of fact, I have this problem just when i run my program on Mac, i haven't it on windows or linux. The separator is incorrectly placed, the text is strikethrough. Does anyone know why?
My code :
JMenuItem fileItem = new JMenuItem("Close");
KeyStroke ...
fileItem.add(new JSeparator(JSeparator.HORIZONTAL),BorderLayout.LINE_START);
Screenshot :

Basically your code right now shows that you are assuming
JMenuItemhas a defaultBorderLayout, which could be true (but I dont think so).Though the root problem is you are adding the
JSeparatorto theJMenuItemwhen in fact you should add it to theJMenuwhich contains the variousJMenuItems viaJMenu#addSeparator(). See How to Use Separators for more.You should be doing something like:
giving you something like:
UPDATE:
Here is an example: