提交 e8510841 编写于 作者: A alexp

6883341: SWAT: jdk7-b72 swat build(2009-09-17) threw exceptions when running...

6883341: SWAT: jdk7-b72 swat build(2009-09-17) threw exceptions when running Java2D demo by clicking Paint ta
Reviewed-by: peterz
上级 536fdc1b
......@@ -250,15 +250,23 @@ public class SwingUtilities2 {
* Returns the left side bearing of the first character of string. The
* left side bearing is calculated from the passed in
* FontMetrics. If the passed in String is less than one
* character, this will throw a StringIndexOutOfBoundsException exception.
* character {@code 0} is returned.
*
* @param c JComponent that will display the string
* @param fm FontMetrics used to measure the String width
* @param string String to get the left side bearing for.
* @throws NullPointerException if {@code string} is {@code null}
*
* @return the left side bearing of the first character of string
* or {@code 0} if the string is empty
*/
public static int getLeftSideBearing(JComponent c, FontMetrics fm,
String string) {
return getLeftSideBearing(c, fm, string.charAt(0));
int res = 0;
if (!string.isEmpty()) {
res = getLeftSideBearing(c, fm, string.charAt(0));
}
return res;
}
/**
......
/*
* Copyright 2009 Sun Microsystems, Inc. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6883341
* @summary Checks that menu items with no text don't throw an exception
* @author Alexander Potochkin
* @run main bug6883341
*/
import javax.swing.*;
public class bug6883341 {
private static void createGui() {
JPopupMenu menu = new JPopupMenu();
menu.add(new JMenuItem());
menu.setVisible(true);
menu.setVisible(false);
}
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
bug6883341.createGui();
}
});
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册