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 /* @test 25 @bug 6777378 26 @summary NullPointerException in XPDefaultRenderer.paint() 27 @author Alexander Potochkin 28 @run main bug6777378 29 */ 30 31 import sun.awt.SunToolkit; 32 33 import javax.swing.*; 34 import javax.swing.table.AbstractTableModel; 35 import javax.swing.table.JTableHeader; 36 import javax.swing.plaf.metal.MetalLookAndFeel; 37 import java.awt.event.MouseEvent; 38 import java.awt.event.InputEvent; 39 import java.awt.*; 40 41 public class bug6777378 { 42 private static JFrame frame; 43 private static JTableHeader header; 44 45 public static void main(String[] args) throws Exception { 46 SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); 47 Robot robot = new Robot(); 48 robot.setAutoDelay(20); 49 SwingUtilities.invokeAndWait(new Runnable() { 50 public void run() { 51 try { 52 UIManager.setLookAndFeel(new MetalLookAndFeel()); 53 } catch (Exception e) { 54 e.printStackTrace(); 55 } 56 JTable table = new JTable(new AbstractTableModel() { 57 public int getRowCount() { 58 return 10; 59 } 60 61 public int getColumnCount() { 62 return 10; 63 } 64 65 public Object getValueAt(int rowIndex, int columnIndex) { 66 return "" + rowIndex + " " + columnIndex; 67 } 68 }); 69 70 header = new JTableHeader(table.getColumnModel()); 71 header.setToolTipText("hello"); 72 73 frame = new JFrame(); 74 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 75 frame.add(header); 76 77 frame.setSize(300, 300); 78 frame.setVisible(true); 79 } 80 }); 81 toolkit.realSync(); 82 Point point = header.getLocationOnScreen(); 83 robot.mouseMove(point.x + 20, point.y + 50); 84 robot.mouseMove(point.x + 30, point.y + 50); 85 robot.mousePress(InputEvent.BUTTON1_MASK); 86 robot.mouseRelease(InputEvent.BUTTON1_MASK); 87 } 88 }