This java program demonstrates the problem.

import java.awt.*;
import javax.swing.*;
import com.sun.java.swing.plaf.gtk.*;

public class Menu {
        public static void main(String[] args) {
                SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                                try {
                                        UIManager.setLookAndFeel(new 
GTKLookAndFeel());

                                        JFrame f = new JFrame("Menu-Test");
                                        JMenuBar b = new JMenuBar();
                                        JMenu m = new JMenu("Menu");
                                        m.add(new JMenuItem("Foo"));
                                        m.add(new DebugSeparator());
                                        m.add(new JMenuItem("Bar"));
                                        b.add(m);
                                        f.setJMenuBar(b);

                                        f.setSize(300, 100);
                                        f.setLocationRelativeTo(null);
                                        
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                                        f.setVisible(true);
                                } catch (Exception exc) {
                                        throw new RuntimeException(exc);
                                }
                        }
                });
        }

        static class DebugSeparator extends JSeparator {
                public Dimension getPreferredSize() {
                        Dimension d = super.getPreferredSize();
                        System.out.println(d);
                        return d;
                }
        }
}

Executing the program and clicking on the menu results in this output.

java.awt.Dimension[width=4,height=6]
java.awt.Dimension[width=4,height=6]
java.awt.Dimension[width=4,height=6]
java.awt.Dimension[width=2,height=0]
java.awt.Dimension[width=2,height=0]

The separator is assigned a zero height and consequently gets clipped in
the painting process.
When the separator size is fixed manually, the separators show up again.

static class DebugSeparator extends JSeparator {
        public Dimension getPreferredSize() {
                Dimension d = super.getPreferredSize();
                d.height = 4;
                return d;
        }
}

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to