osx, java7 screen menu empty after frame.dispose

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Wed Apr 17 07:29:30 PDT 2013


HI,Roger.
Looks like this is a known issue.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8007006
Fixed in jdk 8 and jdk7uX.

On 4/17/13 5:40 PM, Roger Tönz wrote:
> hi
>
> i've got a little Problem with the ScreenMenu
>
> I've several Windows with their own JMenuBar.
>
> When one of the Frames is closed with the DISPOSE_ON_CLOSE behavior, the apple-screenmenu is empty.
>
> Below a little Example.
>
> Roger
>
> Mac OS X 10.8, Java 1.7u17
>
>
>
>
> import java.awt.event.ActionEvent;
> import java.awt.event.ActionListener;
> import javax.swing.JFrame;
> import javax.swing.JMenu;
> import javax.swing.JMenuBar;
> import javax.swing.JMenuItem;
> import javax.swing.JTextArea;
> import javax.swing.WindowConstants;
>
> public class SwingFrameTest extends JFrame {
>
>    static int counter = 0;
>
>
>    public static void main(String[] args) {
>      System.setProperty("apple.laf.useScreenMenuBar", "true");
>      
>      SwingFrameTest frameTest = new SwingFrameTest();
>      frameTest.setTitle( "MainWindow");
>      JTextArea text = new JTextArea();
>      text.setText("Open two Window with the Menu=>Windows=>new\n and then close one. \nNow the Menu is empty");
>      frameTest.getContentPane().add(text);
>      initMenuBar(frameTest);
>      frameTest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>      frameTest.setVisible(true);
>    }
>
>    static void initMenuBar(final JFrame frame){
>      frame.setSize(400, 400);
>      frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
>      JMenuBar bar = new JMenuBar();
>      bar.add(new JMenu(frame.getTitle()));
>      
>      if(frame instanceof SwingFrameTest){
>        JMenu datei = new JMenu("Windows");
>        bar.add(datei);
>        JMenuItem item = new JMenuItem("new");
>        datei.add(item);
>        item.addActionListener(new ActionListener(){
>
>          @Override
>          public void actionPerformed(ActionEvent e) {
>            JFrame newFrame = new JFrame("Frame"+counter++);
>            initMenuBar(newFrame);
>            newFrame.setVisible(true);
>          }});
>      }
>
>      frame.setJMenuBar(bar);
>    }
>
>
> }
>


-- 
Best regards, Sergey.



More information about the macosx-port-dev mailing list