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

Swing's ComboBox Popup opens and closes immediately

    XMLWordPrintable

Details

    • b23
    • x86
    • windows_10

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0_112"
      Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
      Java HotSpot(TM) Client VM (build 25.112-b15, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.15063]

      A DESCRIPTION OF THE PROBLEM :
      When clicking the right-most pixel of a JComboBox the related Popup opens and closes immediately. Happens on any tested Look & Feel (Metal, Windows, Nimbus, BizLookAndFeel).

      The problem seems located in BasicComboPopup.Handler.mouseReleased() :

          // ... more code
          Rectangle bounds = new Rectangle( 0, 0, size.width - 1, size.height - 1 );
          // ... more code

      bounds' width and height shouldn't get reduced by one pixel.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Start SSCCE
      2. Click on the right-most edge of the JComboBox
      3. Watch the popup open and vanish again

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The Popup should stay open.
      ACTUAL -
      The popup closes again.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package de.centigrade.bizlaf;

      import java.awt.Container;
      import java.awt.FlowLayout;

      import javax.swing.JComboBox;
      import javax.swing.JFrame;
      import javax.swing.SwingUtilities;

      public class SSCCE {

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

                  @Override
                  public void run() {
                      new SSCCE().start();
                  }
              });
          }

          public void start() {
              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Container contentPane = frame.getContentPane();
              JComboBox<String> comboBox = new JComboBox<String>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" });
              contentPane.setLayout(new FlowLayout());
              contentPane.add(comboBox);
              frame.setLocationRelativeTo(null);
              frame.pack();
              frame.setVisible(true);
          }
      }
      ---------- END SOURCE ----------

      Attachments

        1. SSCCE.java
          0.9 kB
          Pardeep Sharma

        Issue Links

          Activity

            People

              psadhukhan Prasanta Sadhukhan
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: