changeset 11868:c7233c2411a3

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 13b1ca669311
children 5bf5794f6193
files src/java.desktop/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/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java	Wed Apr 29 16:02:57 2015 -0700
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java	Thu Apr 30 14:04:39 2015 +0400
@@ -992,7 +992,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<Object> renderer = comboBox.getRenderer();
                 if (renderer == null)  {
--- a/test/javax/swing/JComboBox/6632953/bug6632953.java	Wed Apr 29 16:02:57 2015 -0700
+++ 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);
+                }
+            }
+        });
     }
 }