# HG changeset patch # User alexsch # Date 1430388279 -14400 # Node ID fa5b43603cf2684ee8c6b65081be3a90ca6c2133 # Parent a9845d3a9faba9924e6411367e198a2261ae4166 8078614: WindowsClassicLookAndFeel MetalComboBoxUI.getbaseLine fails with IllegalArgumentException Reviewed-by: serb, azvegint, alexsch Contributed-by: Victor Dyakov diff -r a9845d3a9fab -r fa5b43603cf2 src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java --- 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) { diff -r a9845d3a9fab -r fa5b43603cf2 test/javax/swing/JComboBox/6632953/bug6632953.java --- 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); + } + } + }); } }