changeset 14936:fa5b43603cf2

8078614: WindowsClassicLookAndFeel MetalComboBoxUI.getbaseLine fails with IllegalArgumentException Reviewed-by: serb, azvegint, alexsch Contributed-by: Victor Dyakov <victor.dyakov@oracle.com>
author alexsch
date Thu, 30 Apr 2015 14:04:39 +0400
parents a9845d3a9fab
children 27b6d9a2b8a3
files src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java test/javax/swing/JComboBox/6632953/bug6632953.java
diffstat 2 files changed, 27 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java	Sat Jul 25 01:02:51 2020 -0300
+++ b/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java	Thu Apr 30 14:04:39 2015 +0400
@@ -954,7 +954,7 @@
         getDisplaySize();
         if (sameBaseline) {
             Insets insets = c.getInsets();
-            height = height - insets.top - insets.bottom;
+            height = Math.max(height - insets.top - insets.bottom, 0);
             if (!comboBox.isEditable()) {
                 ListCellRenderer renderer = comboBox.getRenderer();
                 if (renderer == null)  {
--- a/test/javax/swing/JComboBox/6632953/bug6632953.java	Sat Jul 25 01:02:51 2020 -0300
+++ b/test/javax/swing/JComboBox/6632953/bug6632953.java	Thu Apr 30 14:04:39 2015 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,23 +22,39 @@
  */
 
 /* @test
- * @bug 6632953
+ * @bug 6632953 8078614
  * @summary MetalComboBoxUI.getBaseline(JComponent, int, int) throws IAE for valid width/height
  * @author Alexander Potochkin
  */
-
 import javax.swing.JComboBox;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
 import javax.swing.plaf.metal.MetalComboBoxUI;
 
 public class bug6632953 {
 
     public static void main(String... args) throws Exception {
-        MetalComboBoxUI ui = new MetalComboBoxUI();
-        ui.installUI(new JComboBox());
-        ui.getBaseline(new JComboBox(), 0, 0);
-        ui.getBaseline(new JComboBox(), 1, 1);
-        ui.getBaseline(new JComboBox(), 2, 2);
-        ui.getBaseline(new JComboBox(), 3, 3);
-        ui.getBaseline(new JComboBox(), 4, 4);
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+
+                for (UIManager.LookAndFeelInfo lafInfo
+                        : UIManager.getInstalledLookAndFeels()) {
+                    try {
+                        UIManager.setLookAndFeel(lafInfo.getClassName());
+                    } catch (Exception e) {
+                        throw new RuntimeException(e);
+                    }
+                    MetalComboBoxUI ui = new MetalComboBoxUI();
+                    ui.installUI(new JComboBox());
+                    ui.getBaseline(new JComboBox(), 0, 0);
+                    ui.getBaseline(new JComboBox(), 1, 1);
+                    ui.getBaseline(new JComboBox(), 2, 2);
+                    ui.getBaseline(new JComboBox(), 3, 3);
+                    ui.getBaseline(new JComboBox(), 4, 4);
+                }
+            }
+        });
     }
 }