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

Option dialog hidden when tooltip showed

XMLWordPrintable

    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_21"
      Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
      Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      customer Windows XP SP2 [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      If popup menu shows out of main frame boundary then open an option dialog which is not bind to main frame . After that , when click the main frame , the option dialog will hide behind main frame .

      This happens in 1.6.0_12 , 1.6.0_18 and 1.6.0_21 .
      This doesn’t happen in 1.60._7 , 1.6.0_10 .


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Right Click main frame to let the popup shows out of the main frame boundary .
      2) Click the ‘open dialog’ button to open an option dialog .
      3) Click the main frame , the opened option dialog will hide behind main frame.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The option dialog is a model dialog , which won’t hide behind main frame.
      ACTUAL -
      Main frame can receive focus and option dialog will hide behind main frame.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Dimension;
      import java.awt.EventQueue;
      import java.awt.Point;
      import java.awt.Toolkit;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.awt.event.MouseAdapter;
      import java.awt.event.MouseEvent;
      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JMenuItem;
      import javax.swing.JOptionPane;
      import javax.swing.JPopupMenu;
      import javax.swing.JTextArea;

      public class JPopupMenuDemo extends JFrame{

      private static final long serialVersionUID = 1L;

      public static void main(String[] args) {
      EventQueue.invokeLater(new Runnable(){

      @Override
      public void run() {
      new JPopupMenuDemo().setVisible(true);
      }
      });
      }

      public JPopupMenuDemo(){
      initComponents();
      }

      private void initComponents() {
      JButton openBtn = new JButton("Open dialog");
      openBtn.setBounds(10, 10, 150, 30);
      openBtn.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent evt) {
               Object[] options = new Object[2];
               options[0] = "YES";
               options[1] = "NO";
               //if the opion dialog isn't bind to its parent frame ,this problem will show up.
               JOptionPane.showOptionDialog(getContentPane(), "This dialog will hidden behind parent frame \r\n when jpopupmenu show outside main frame.", "Info",
               JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);
                  }
              });

      final JPopupMenu popupMenu = new JPopupMenu("Popup");
      JMenuItem item = new JMenuItem("Close");
      popupMenu.add(item);



      getContentPane().setPreferredSize(new Dimension(400,400));
      getContentPane().setLayout(null);
              getContentPane().add(openBtn);
      getContentPane().addMouseListener(new MouseAdapter() {
      public void mousePressed(MouseEvent evt) {
      popupMenu.show(JPopupMenuDemo.this, evt.getX(), evt.getY());
      }
      });

      JLabel tipLabel = new JLabel("<html>"+
      "<a href=#>if the opion dialog isn't bind to its parent frame,the demo shows nomally in 1.6.0u7 and 1.6.0u10 version but abnormally in 1.6.0u12,1.6.0u18 and latest 1.6.0u21</a><br>"+
      "step1:click 'open dialog' button<br>step2:click the main frame,the option dailog won't hide behind parent frame<br>"+
      "[case1]:(no problem)<br>step3:right click main frame and the popup menu shows in the mainframe<br>step4:click 'open dialog' button<br>step5:click main frame,the option dialog won't hide behind parent frame<br>"+
      "[case2]:<br>step3:right click main frame near the boundary to let the popup menu show outside the frame<br>step4:click 'open dialog' button<br>step5:click the main frame,the option dialog will hide behind parent frame"
      +"</html>"
      );
      tipLabel.setBounds(40, 40, 350,350);
      getContentPane().add(tipLabel);
              
              setTitle("JPopupMenu Demo");
      pack();

              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              Dimension frameSize = getSize();
              setLocation(new Point((screenSize.width - frameSize.width) / 2,
                                    (screenSize.height - frameSize.width) / 2));
      }
      }

      ---------- END SOURCE ----------
      I can't reporoduce it on my Vista

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: