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

Popup menu from JComboBox disppears behind the main window on scrolling

    XMLWordPrintable

Details

    Description

      When the popup of a JComboBox exceeds beyond the parent frame, on
      scrolling, the popup menu disappears behind the main windows. This is not the
      case when the size of the combobox does not exceed beyond the frame.
      Following is an example showing the inconsistency. JComboBox combo1
      exceeds beyond the frame while JComboBox combo2 does not.
      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;
      import java.awt.print.*;
      import java.io.*;
      import javax.swing.JFrame;
      import javax.swing.event.*;
      import java.util.*;

      public class ComboFocusDemo extends JFrame
      {
          protected JComboBox combo1;
          protected JComboBox combo2;
          
          public ComboFocusDemo()
         {
           //to fill sample data in to the vector
              Vector vec = fillVector();
              
              Container mypanel = this.getContentPane();
              this.setBounds(10,10,400,150);

              JPanel p = new JPanel(new FlowLayout());
              p.setBounds(0,0,350,120);

              combo1 = new JComboBox(vec);
              combo1.setEditable(true);
              combo1.setBounds(5,5,80,32);

             combo2 = new JComboBox(vec);
             combo2.setEditable(true);
             combo2.setBounds(85,5,80,32);
      //setting the visible fields so that the pop would fit within the frame.
             combo2.setMaximumRowCount(3);

              p.add(combo1);
              p.add(combo2);
              mypanel.add(p,BorderLayout.NORTH);
              p.setVisible(true);
              this.setVisible(true);
          }


          /**
           * Func to fill sample data in to the vector
           */
          public Vector fillVector()
          {
                Vector datavec= new Vector();
                    datavec.addElement("One");
                    datavec.addElement("Two");
                    datavec.addElement("Three");
                    datavec.addElement("Four");
                    datavec.addElement("Five");
                    datavec.addElement("Six");
                    datavec.addElement("Seven");
                    datavec.addElement("Eight");
                    datavec.addElement("Nine");
                    datavec.addElement("Ten");
                    datavec.addElement("Eleven");
                    datavec.addElement("Twelve");
                    datavec.addElement("Thirteen");
                    datavec.addElement("Fourteen");
                return datavec;
          }//end of fill data

          public static void main (String args[])
          {
             ComboFocusDemo myclick = new ComboFocusDemo();
          }
      }//end of the class


      The problem is seen with latest bits of merlin on Solaris.

      With JDK 1.4 build 85, 86 I could reproduce the problem

      Attachments

        Activity

          People

            alexp Alexander Potochkin (Inactive)
            cprasadsunw Ck Prasad (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: