Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4189244

Swing Popup menu is not being refreshed (cleared) under a Dialog

XMLWordPrintable

    • ladybird
    • generic, x86
    • generic, solaris_7, windows_95, windows_98, windows_nt

        ve the Frame to the upper left corner of the screen
         - right click the mouse over the Test label.
         - Press any one of the Test menu items that appear.
         - Note that a JDialog appears that covers the
           entire frame.
         - without moving this Dialog, press the close button
         - Note that now on the main frame, the
            Popup Menu still shows up, even though it isn't really
            there.

        This Test label is just not getting redrawn, so it
        still shows as if the popup menu was there.


        import java.awt.*;
        import java.awt.event.*;
        import javax.swing.*;
        import javax.swing.border.EmptyBorder;
         
        public class BadDialog1 extends JPanel implements ActionListener
        {
            static JFrame frame;
            JPopupMenu popupMenu;
            JButton quitButton = null;
            JButton closeButton = null;
            JDialog badDialog = null;

            public BadDialog1()
            {
                setLayout(new BorderLayout());
                JLabel testLabel = new JLabel("Test");
                testLabel.addMouseListener(new MouseAdapter()
                {
                    public void mousePressed(MouseEvent e)
                    {
                        if(e.isPopupTrigger())
                        {
                            popupMenu.show((Component)e.getSource(), e.getX(), e.getY());
                        }
                    }
                    public void mouseReleased(MouseEvent e)
                    {
                        if(e.isPopupTrigger())
                        {
                            popupMenu.show((Component)e.getSource(), e.getX(), e.getY());
                        }
                    }
                });
                setBorder(new EmptyBorder(10, 10, 10, 10));
                createBadDialog();
                quitButton = new JButton("Quit");
                quitButton.addActionListener(this);
                add("Center", testLabel);
                add("South", quitButton);
                popupMenu = new JPopupMenu();
                JMenuItem item1 = new JMenuItem("Test1");
                item1.addActionListener(this);
                JMenuItem item2 = new JMenuItem("Test2");
                item2.addActionListener(this);
                JMenuItem item3 = new JMenuItem("Test3");
                item3.addActionListener(this);
                JMenuItem item4 = new JMenuItem("Test4");
                item4.addActionListener(this);
                popupMenu.add(item1);
                popupMenu.add(item2);
                popupMenu.add(item3);
                popupMenu.add(item4);
            }

            public static void main(String[] args)
            {
                int INITIAL_WIDTH = 300;
                int INITIAL_HEIGHT = 250;
                frame = new JFrame("BadDialog");
         
                BadDialog1 test = new BadDialog1();
         
                frame.addWindowListener(new WindowAdapter()
                {
                    public void windowClosing(WindowEvent e)
                    {
                        System.exit(0);
                          frame.setVisible(true);
                    }
                    public void windowClosed(WindowEvent e)
                    {
                      System.out.println("In windowClosed");
                    }
                });
                frame.getContentPane().add("Center", test);
                frame.pack();
                frame.setSize(INITIAL_WIDTH, INITIAL_HEIGHT);
                Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
                frame.setLocation(screenSize.width/2 - INITIAL_WIDTH/2,
                   screenSize.height/2 - INITIAL_HEIGHT/2);
                frame.setVisible(true);
            }

            private void createBadDialog()
            {
                badDialog = new JDialog();
                badDialog.getContentPane().setLayout(new BorderLayout());
                JPanel centerPanel = new JPanel(new GridLayout(1, 1));
                centerPanel.setPreferredSize(new Dimension (800, 500));
                badDialog.getContentPane().add("Center", centerPanel);
                closeButton = new JButton("Close");
                closeButton.addActionListener(this);
                badDialog.getContentPane().add("South", closeButton);
                badDialog.pack();
            }

            public void actionPerformed(ActionEvent event)
            {
                Object source = event.getSource();
                if(source == quitButton)
                    System.exit(0);
                else if(source == closeButton)
                    badDialog.setVisible(false);
                else
                    badDialog.setVisible(true);
            }
        }
        (Review ID: 94270)
        ======================================================================

        Name: skT88420 Date: 09/02/99


        Since I got reply of "not able to reproduce" twice from you, this time I will attach a example which is modified from a sample program in java tutorial. The attached code is for two different file, one is called PopupMenuDemo, another called TestDialog. Please run it and try to reproduce the bug. The bug occurs when the dialog cover PART of the popup menu and then is closed without moving.

        import java.awt.*;
        import java.awt.event.*;
        import javax.swing.*;

        /*
         * This class adds popup menus to MenuDemo.
         */
        public class PopupMenuDemo extends JFrame
                                   implements ActionListener {
            JTextArea output;
            JScrollPane scrollPane;
            JPopupMenu popup;

            public PopupMenuDemo() {
                JMenuBar menuBar;
                JMenu menu, submenu;
                JMenuItem menuItem;
                JRadioButtonMenuItem rbMenuItem;
                JCheckBoxMenuItem cbMenuItem;

                addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent e) {
                        System.exit(0);
                    }
                });

                //Add regular components to the window, using the default BorderLayout.
                Container contentPane = getContentPane();
                output = new JTextArea(5, 30);
                output.setEditable(false);
                scrollPane = new JScrollPane(output);
                contentPane.add(scrollPane, BorderLayout.CENTER);

                //Create the menu bar.
                menuBar = new JMenuBar();
                setJMenuBar(menuBar);

                //Build the first menu.
                menu = new JMenu("A Menu");
                menu.setMnemonic(KeyEvent.VK_A);
                menuBar.add(menu);

                //Build second menu in the menu bar.
                menu = new JMenu("Another Menu");
                menu.setMnemonic(KeyEvent.VK_N);
                menu.getAccessibleContext().setAccessibleDescription(
                        "This menu does nothing");
                menuBar.add(menu);

                //Create the popup menu.
                popup = new JPopupMenu();
                menuItem = new JMenuItem("A popup menu item");
                menuItem.addActionListener(this);
                popup.add(menuItem);
                menuItem = new JMenuItem("Another popup menu item");
                menuItem.addActionListener(this);
                popup.add(menuItem);

                //Add listener to components that can bring up popup menus.
                MouseListener popupListener = new PopupListener();
                output.addMouseListener(popupListener);
                scrollPane.addMouseListener(popupListener);
                menuBar.addMouseListener(popupListener);
            }

            public void actionPerformed(ActionEvent e) {
              TestDialog dlg = new TestDialog();
              int x = this.getLocation().x + 50;
              int y = this.getLocation().y + 50;
              dlg.setLocation( x, y );
              dlg.setVisible(true);
            }

            public static void main(String[] args) {
            try{
            UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
            }
            catch( Exception e )
            {
            }
                PopupMenuDemo window = new PopupMenuDemo();

                window.setTitle("PopupMenuDemo");
                window.setSize(450, 260);
                window.setVisible(true);
            }

            class PopupListener extends MouseAdapter {
                public void mousePressed(MouseEvent e) {
                    maybeShowPopup(e);
                }

                public void mouseReleased(MouseEvent e) {
                    maybeShowPopup(e);
                }

                private void maybeShowPopup(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        popup.show(e.getComponent(),
                                   e.getX(), e.getY());
                    }
                }
            }
        }

        import java.awt.*;
        import java.awt.event.*;
        import javax.swing.*;

        public class TestDialog extends JDialog implements ActionListener
        {
          JPanel panel1 = new JPanel();
          BorderLayout borderLayout1 = new BorderLayout();

          public TestDialog(Frame frame, String title, boolean modal)
          {
            super(frame, title, modal);
            try
            {
              jbInit();
              pack();
            }
            catch(Exception ex)
            {
              ex.printStackTrace();
            }
            setSize( 300, 200 );
          }

          public TestDialog()
          {
            this(null, "", false);
          }

          void jbInit() throws Exception
          {
            panel1.setLayout(borderLayout1);
            getContentPane().add(panel1);
            JButton close = new JButton("Close me!");
            panel1.add( close, BorderLayout.CENTER );
            close.addActionListener(this);
          }

          public void actionPerformed( ActionEvent e )
          {
            setVisible(false);
          }
        }
        (Review ID: 94799)
        ======================================================================

        Name: skT88420 Date: 10/11/99


        Show up a frame that has DO_NOTHING_ON_CLOSE as the defaultCloseOperation, click on a menu and when the menu is still showing up, click on the X button on the right-top corner to close the window. In the windowClosing () method, call the setVisible (false) method to hide the window. Call setVisible (true) again to show the same frame, you can see that the menu is still open.

        Run the following program to understand the problem:
            - javac Menu.java
            - java Menu
            - Click on "Open" button.
            - Click on the "File" menu.
            - Click on the "X" button when the menu is still seen.
            - Click on the "Open" button again.

        ----Menu.java----
        import java.awt.*;
        import java.awt.event.*;
        import javax.swing.*;
        import javax.swing.event.*;
        import javax.swing.border.*;

        public class Menu extends JFrame
        {
            JFrame otherFrame;

            public Menu (String title)
            {
                super (title);
                JButton but = new JButton ("Open");
                but.addActionListener (new ActionListener ()
                    {
                        public void actionPerformed (ActionEvent e)
                        {
                            if (otherFrame == null) {
                                otherFrame = new OtherFrame ();
                            }
                            otherFrame.show ();
                        }
                    });
                getContentPane ().add (but);
            }

            public static void main (String[] args)
            {
                Menu app = new Menu ("Menu");
                app.pack ();
                app.show ();
            }

            static class OtherFrame extends JFrame
            {
                OtherFrame ()
                {
                    JMenuBar jmb = new JMenuBar ();
                    JMenu jm = new JMenu ("File");
                    jm.add (new JMenuItem ("Open"));
                    jm.add (new JMenuItem ("Save"));
                    jmb.add (jm);
                    setJMenuBar (jmb);
                    setDefaultCloseOperation (DO_NOTHING_ON_CLOSE);
                    addWindowListener (new WindowAdapter ()
                        {
                            public void windowClosing (WindowEvent ev)
                            {
                                setVisible (false);
                            }
                        });
                    setSize (200, 100);
                }
            }
        }
        ----Menu.java----

        This happens even if you set Windows LnF. Also the menus are not hidden when the window is moved. On windows, the default behavior is to hide them when the window is moved/deactivated/deiconified.
        (Review ID: 96387)
        ======================================================================

        Name: skT88420 Date: 11/10/99


        java version "1.2.1"
        classic vm (build JDK-1.2.1-A, native threads)

        - i have an application with a frame (JFrame) that has a menu bar
        - if i open a menu (in my java application) and then i click another
        application (my application loses focus) the menu is still shown. it is not
        destroyed or the frame doesn't repaint
        - i think it is the last one because one of my menus opens a JFileChooser that
        apears over the menu (the frame is a small one). if i close the this window
        (the file chooser) the menu is still shown. but if i move the file chooser the
        frame (probably) repaints corectly so the menu id gone.
        (Review ID: 97653)
        ======================================================================

        Name: skT88420 Date: 11/10/99


        jdk 1.1.8, swing-1.1.1fcs
        /*
            Start with java Slow
            Press mouse button, release mouse button, select item 1, 2, 1, 2 and so on.
            You should see, that the subMenu of 1 does not pop up immediately, but with
        some delay. Thats ok.
            Now press mouse button but do no release it, then drag to item 1, 2, 1, 2
        and so on.
            You should observe, that the subMenu shows up immediately. Sounds to be ok,
        but it is different to
            the above behaviour.
            I claim, that in the second case, the subMenu is painted twice! Immediately
        and after the usual delay.
            This results in a performance problem with popups. (on slow computers
        selecting in dragging mode
            is so awefully slowly, that it almost killed a java project).
            The fix to bug 4188027 causes the problem.
        */

        import javax.swing.*;
        import java.awt.event.*;

        public class Slow extends JFrame
        {
            
            public static final void main ( String[] args ) {
               
               final JFrame f = new JFrame();
               f.setSize(500,500);
               final JPopupMenu popupMenu = new JPopupMenu();

               JMenu menu = new JMenu(" 1 ");
               popupMenu.add(menu);
               popupMenu.add(new JMenuItem(" 2 "));

               menu.add(new JMenuItem("subMenu"));

               f.getContentPane().addMouseListener(new MouseAdapter() {
                   public void mousePressed(MouseEvent e) {
        popupMenu.show(f.getContentPane(),100,100);
        }
               });
               
               f.setVisible(true);
            }
        }
        (Review ID: 97647)
        ======================================================================


        Name: rk38400 Date: 11/11/98


        the following program show evidence that a popup menu is
        not cleared properly if the action on the popup was bringing
        a JOptionPane to display a message.
        The following test must be performed several times
        to see the problem. On my platform, NT4 and SP3
        occurs after max 5 tests.

        // Author : Bruno Coudoin
        //
        // Show evidence that the popup is not refreshed properly under a joptionpane
        // Note that if the frame is smaller and the popup goes beyond its limit, then
        // the problem do not appear

        import javax.swing.*;
        import java.util.*;
        import java.awt.*;
        import java.awt.event.*;

        public class refreshBug extends JPanel implements ActionListener {
            JPopupMenu _jPopupMenu = new JPopupMenu();

            public void init() {
        JMenuItem menuItem;
        JButton jb = new JButton("Bring the popup here and select an item");

        this.add(jb, BorderLayout.CENTER);

        for(int i=1; i<10; i++) {
        menuItem = new JMenuItem("Item "+i);
        menuItem.addActionListener(this);
        _jPopupMenu.add(menuItem);
        }

        MouseListener ml = new MouseAdapter() {
        public void mouseReleased(MouseEvent e) {
        if(e.isPopupTrigger()) {
        _jPopupMenu.show(e.getComponent(),
        e.getX(), e.getY());
        }
        }
        };
        this.addMouseListener(ml);

        jb.addMouseListener(ml);

            }

            // An action is requested by the user
            public void actionPerformed(java.awt.event.ActionEvent e) {

        JOptionPane.showMessageDialog(this,
        "Check if there is some popup left under me\n"+
        "if not, retry and let the popup appear where i am",
        "WARNING",
        JOptionPane.WARNING_MESSAGE);

        // Even this don't work
        _jPopupMenu.setVisible(false);
            }

            // Main
            public static void main(String[] args) {
        refreshBug applet = new refreshBug();
        JFrame frame = new JFrame();

        frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
        System.exit(0);
        }
        });

        frame.setTitle("Popup refresh bug");
        frame.getContentPane().add(applet, BorderLayout.CENTER);
        applet.init();
        frame.setSize(400,400);
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
        frame.setVisible(true);
            }

        }
        (Review ID: 41943)
        ======================================================================

        Name: krT82822 Date: 04/11/99


        This problem occurs in NT 4.0 sp3, Win95, Win98
        This problem occurs in JDK1.2, JDK1.2.1, and EA JDK1.2.2 (was
        renumbered from JDK-1.2.1-K, native threads, symcjit )

        This problem has been previously reported as bug #4189244,
        but this example reproduces the problem more reliably.

        When a JMenuItem's ActionListener displays a dialog box which
        obscures some of the menu, then the underlying component does not
        properly repaint when the dialog box is dismissed. The full or
        partial image of the popped up menus remains visible.

        This happens for either modal or non-modal dialog boxes, but does
        not happen for obscuring Frames.


        The following code will reproduce the problem.

        The paint routine has been deliberately slowed down so that
        the problem will reproduce itself every time. It can be seen
        that the repaint of the underlying panel occurs while the dialog
        box is being displayed. The correct areas of the panel obscured
        by the popup menus are repainting, but the screen is not being
        updated. When the Dialog box is closed by clicking on the button,
        the underlying panel does not repaint, because it thinks that the
        screen is up to date.

        Two of the three menu choices will reproduce the problem:

        1) When the dialog box completely obscures the parent frame
        2) When the dialog box partially obscures the menu bar.

        In the third case, when the menu bar is completely unobscured,
        but the panel is partially obscured, there is no bug.

        If double buffering is turned off, the bug does not appear.

        This does not appear to be a JMenu bug per se, but a general
        java.awt.Component paint problem ( w. Double buffering )
        because this situation can be reproduced in another way:

        1) In a swing application, bring up a print dialog.
        2) Move the dialog so that it partially overlaps the main frame
        3) Now bring up the "properties" dialog from the print dialog
           It should overlap the print dialog and the application frame.
        4) Close the dialogs and the image of the print dialog will remain
           on the swing application where the print dialog was obscured
           by the properties dialog.



        --------------- MenuRedrawBug.java --------------
        import java.awt.*;
        import java.awt.event.*;
        import javax.swing.*;
        import javax.swing.event.*;

        class TestPanel extends JPanel
            {
            int id;
            public TestPanel( int i )
                {
                super();
                id = i;
                }
            public void paint(Graphics g)
                {
                try
                    {
                    System.out.print("paint " + id);
                    Thread.sleep(500);
                    }
                catch ( Throwable t )
                    {}
                super.paint(g);
                System.out.println(" .....done");
                }
            }

        class TestDialog extends JDialog
            {
        JPanel containerPanel = new JPanel();
        Window parent;
        public TestDialog( Frame f)
             {
             super(f);
             parent = f;
             myInit();
             }
            public TestDialog( Frame f, boolean b)
             {
             super(f,b);
             parent = f;
             myInit();
             }
            private void myInit()
                {
                JButton closeButton = new JButton("Click to close Dialog");
                containerPanel.setLayout(new BorderLayout());
                containerPanel.add( BorderLayout.CENTER, closeButton);
                closeButton.addActionListener( new ActionListener()
                    {
                    public void actionPerformed( ActionEvent e )
                        {
                        TestDialog.this.setVisible(false);
                        TestDialog.this.dispose();
                        }
                    });
             getContentPane().add(containerPanel);
                }
            }

        public class MenuRedrawBug extends JFrame
            {
        public MenuRedrawBug()
             {
             super();
                setTitle("MenuRedrawBug");
                addWindowListener(new WindowAdapter()
                    {
                    public void windowClosing(WindowEvent e)
                        {
                        System.exit(0);
                        }
                    });
                myInit();
                }

            private void myInit()
                {
                JMenuBar menuBar;
                JMenu menu, submenu;
                JMenuItem menuItem;

                Container contentPane = getContentPane();
                contentPane.setLayout(new GridLayout(1,5));
                JPanel p;
                p = new TestPanel(1);
                p.setBackground(Color.red);
                contentPane.add( p );
                p = new TestPanel(2);
                p.setBackground(Color.white);
                contentPane.add( p );
                p = new TestPanel(3);
                p.setBackground(Color.green);
                contentPane.add( p );
                p = new TestPanel(4);
                p.setBackground(Color.yellow);
                contentPane.add( p );
                p = new TestPanel(5);
                p.setBackground(Color.orange);
                contentPane.add( p );

                //Create the menu bar.
                menuBar = new JMenuBar();
                setJMenuBar(menuBar);
                menu = new JMenu("Show Bug");
                menuBar.add(menu);
                submenu = new JMenu("Bug submenu");
                menu.add(submenu);
                menuItem = new JMenuItem("Show completely overlapping dialog");
                menuItem.addActionListener( new ActionListener()
                    {
                    public void actionPerformed(ActionEvent e)
                        {
                        showDialogWithOffset(-10,-10);
                        }
                    });
                submenu.add(menuItem);

                menuItem = new JMenuItem("Show partially overlapping dialog (no bug)");
                menuItem.addActionListener( new ActionListener()
                    {
                    public void actionPerformed(ActionEvent e)
                        {
                        showDialogWithOffset(100,60 );
                        }
                    });
                submenu.add(menuItem);


                menuItem = new JMenuItem("Show partially overlapping dialog (bug)");
                menuItem.addActionListener( new ActionListener()
                    {
                    public void actionPerformed(ActionEvent e)
                        {
                        showDialogWithOffset(60,0 );
                        }
                    });
                submenu.add(menuItem);

                }

            public void showDialogWithOffset ( int xoffset, int yoffset )
                {
        TestDialog window = new TestDialog(this);
        Dimension size = getSize();
        Point location = getLocation();
        // make dialog a little bigger than the JFrame
        window.setSize ( size.width + 30, size.height + 30 );
        location.translate ( xoffset, yoffset );
        window.setLocation ( location );
        window.show();
                }

            public static void main(String[] args)
                {
                MenuRedrawBug window = new MenuRedrawBug();
                window.setSize(450, 260);
                window.setVisible(true);
                }
            }

        ------------------------ end MenuRedrawBug.java --------------
        ======================================================================

        Name: skT88420 Date: 05/12/99


        I have a simple Swing application with a menu bar and 2
        scrollable lists in a JSplitPane. Some of the menu functions
        bring up standard dialogs (JOptionPane dialogs). The problem is
        that after a dialog is dismissed, the app's main window does not
        get repainted. The menu still appears to be pulled down, even
        though it is not active.

        I will gladly provide source code, please contact me by email.
        It's too much to include here.

        java -version output:
        java version "1.2.1"
        Classic VM (build JDK-1.2.1-A, native threads)

        java -fullversion output:
        java fullversion "JDK-1.2.1-A"
        (Review ID: 63113)
        ======================================================================

        Name: skT88420 Date: 06/09/99


        I open a dialog through a menu item in which the dialog
        completely covers the menu items list. When the dialog is
        closed, the menu items are still there (it missed a repaint).
        (Review ID: 84133)
        ======================================================================

        Name: skT88420 Date: 06/21/99


        On some Windows 95 systems using JDK 1.2, the Swing components do not function properly. Wherever the cursor is used, the screen components do not refresh properly. For instance, GUI components, such as a menu selection, remain on the screen after the menu collapses. The screen gets more and more corrupted as more cursor/mouse actions are performed. This has been seen on a number of Windows 95 systems as witnessed in some of the java newsgroups such as comp.lang.java.gui.

        It has also been reported on multi-processor NT systems. I discovered the problem when using a couple of JAVA IDEs that were written in Swing. The IDEs (NetBeans DeveloperX2 2.1 and Jasupremo 2.0) are not usable due to these problems. Jasupremo 2.0 is more lightweight, and you can use it to easily reproduce the problem. It is available from www.tucows.com. Please investigate this problem. If people continue to have problems (functional and performance) with Swing, it will likely be rejected by developers.

        Since not all Windows 95 systems witness the problem, I will give you a brief list of common software that is on both of my Windows 95 systems that exhibit the problem: Visual Basic 4.0 and 5.0, Lotus Notes 4.5, Visual Age for Java, and the IBM AS/400 Client/Access product. The two systems have different display drivers (ATI Rage and Matrox Millenium), and so I don't think that's the problem. I run with large fonts, 1024*768 resolution, and 16 or 24 bit color. Everything else (Notes apps, Visual Basic apps,etc) works fine on the PCs. It's just Swing applications that exhibit the problem.
        (Review ID: 53626)
        ======================================================================

        Name: skT88420 Date: 08/20/99


        Hi,

        I've got the following problem with my file menu: When I choose "open" from the menu (see source below), the fileDialog pops up (just like I intended). If it pops up on the spot where the menu was displayed (thus fully covering this spot) and I press cancel, the menu is still displayed when the dialog is closed. The menu does not respond to mouse clicks any more and it disappears when I start clicking on the menu name ("File").

        OK here's the source of my file (nevermind the classname :)

        import javax.swing.*;
        import java.awt.event.*;
        import java.awt.*;
        import java.io.*;

        public class AlienManager extends JFrame
        {
        JMenuBar menubar = new JMenuBar();
        JMenu fileMenu = new JMenu("File");
        JMenuItem newItem = new JMenuItem("New");
        JMenuItem openItem = new JMenuItem("Open");
        JMenuItem saveItem = new JMenuItem("Save");
        JMenuItem saveasItem = new JMenuItem("Save as");
        JMenuItem exitItem = new JMenuItem("Exit");
        JTable aliensTable = new JTable();

        //Create a file chooser
        final JFileChooser fc = new JFileChooser();

        File currentFile = null;

        public AlienManager()
        {
        Container pane= getContentPane();
        buildMenu();
        setSize(400,300);
        addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e)
        {
        closeApplication();
        }
        });
        pane.add("Center", new JScrollPane(aliensTable));
        }

        void buildMenu()
        {
        newItem.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent al)
        {
        }
        });
        openItem.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent al)
        {
        //In response to a button click:
        fc.setDialogType(JFileChooser.OPEN_DIALOG);
        int returnVal = fc.showOpenDialog(AlienManager.this);
        if (returnVal == JFileChooser.APPROVE_OPTION)
        {
                 currentFile = fc.getSelectedFile();
                 }
        }
        });
        saveItem.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent al)
        {
        // save currentFile
        }
        });
        saveasItem.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent al)
        {
        // select a new value for currentFile
        fc.setDialogType(JFileChooser.SAVE_DIALOG);
        int returnVal = fc.showSaveDialog(AlienManager.this);
        if (returnVal == JFileChooser.APPROVE_OPTION)
        {
                 currentFile = fc.getSelectedFile();
                 }
        }
        });
        exitItem.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent al)
        {
        closeApplication();
        }
        });
        fileMenu.add(newItem);
        fileMenu.add(openItem);
        fileMenu.add(saveItem);
        fileMenu.add(saveasItem);
        fileMenu.add(exitItem);
        menubar.add(fileMenu);
        setJMenuBar(menubar);
        }

        public void closeApplication()
        {
        System.exit(0);
        }

        public static void main(String ps[])
        {
        new AlienManager().show();
        }
        }
        (Review ID: 94197)
        ======================================================================

        Name: skT88420 Date: 08/23/99


        A JPopupMenu still appears over the component that invoked it
        if a menu item from this popup menu launches a PopupDialog
        over the popup menu.
        This only occurs if the PopupDiloag is closed without being
        moved or resized.

        I have only seen this problem on NT. It did not
        occur on Solaris.

        Compile and run the program shown below
         - Mo

              son Oleg Sukhodolsky (Inactive)
              rkarsunw Ralph Kar (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: