1 /* 2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 @test 26 @key headful 27 @bug 6777378 28 @summary NullPointerException in XPDefaultRenderer.paint() 29 @author Alexander Potochkin 30 @run main bug6777378 31 */ 32 33 import sun.awt.SunToolkit; 34 35 import javax.swing.*; 36 import javax.swing.table.AbstractTableModel; 37 import javax.swing.table.JTableHeader; 38 import javax.swing.plaf.metal.MetalLookAndFeel; 39 import java.awt.event.MouseEvent; 40 import java.awt.event.InputEvent; 41 import java.awt.*; 42 43 public class bug6777378 { 44 private static JFrame frame; 45 private static JTableHeader header; 46 47 public static void main(String[] args) throws Exception { 48 SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); 49 Robot robot = new Robot(); 50 robot.setAutoDelay(20); 51 SwingUtilities.invokeAndWait(new Runnable() { 52 public void run() { 53 try { 54 UIManager.setLookAndFeel(new MetalLookAndFeel()); 55 } catch (Exception e) { 56 e.printStackTrace(); 57 } 58 JTable table = new JTable(new AbstractTableModel() { 59 public int getRowCount() { 60 return 10; 61 } 62 63 public int getColumnCount() { 64 return 10; 65 } 66 67 public Object getValueAt(int rowIndex, int columnIndex) { 68 return "" + rowIndex + " " + columnIndex; 69 } 70 }); 71 72 header = new JTableHeader(table.getColumnModel()); 73 header.setToolTipText("hello"); 74 75 frame = new JFrame(); 76 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 77 frame.add(header); 78 79 frame.setSize(300, 300); 80 frame.setVisible(true); 81 } 82 }); 83 toolkit.realSync(); 84 Point point = header.getLocationOnScreen(); 85 robot.mouseMove(point.x + 20, point.y + 50); 86 robot.mouseMove(point.x + 30, point.y + 50); 87 robot.mousePress(InputEvent.BUTTON1_MASK); 88 robot.mouseRelease(InputEvent.BUTTON1_MASK); 89 } 90 }