Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JTable/6777378/bug6777378.java
38854 views
/*1* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/* @test24@bug 677737825@summary NullPointerException in XPDefaultRenderer.paint()26@author Alexander Potochkin27@run main bug677737828*/2930import javax.swing.*;31import javax.swing.table.AbstractTableModel;32import javax.swing.table.JTableHeader;33import javax.swing.plaf.metal.MetalLookAndFeel;34import java.awt.event.MouseEvent;35import java.awt.event.InputEvent;36import java.awt.*;3738public class bug6777378 {39private static JFrame frame;40private static JTableHeader header;4142public static void main(String[] args) throws Exception {43Robot robot = new Robot();44robot.setAutoDelay(20);45SwingUtilities.invokeAndWait(new Runnable() {46public void run() {47try {48UIManager.setLookAndFeel(new MetalLookAndFeel());49} catch (Exception e) {50e.printStackTrace();51}52JTable table = new JTable(new AbstractTableModel() {53public int getRowCount() {54return 10;55}5657public int getColumnCount() {58return 10;59}6061public Object getValueAt(int rowIndex, int columnIndex) {62return "" + rowIndex + " " + columnIndex;63}64});6566header = new JTableHeader(table.getColumnModel());67header.setToolTipText("hello");6869frame = new JFrame();70frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);71frame.add(header);7273frame.setSize(300, 300);74frame.setVisible(true);75}76});77robot.waitForIdle();78Point point = header.getLocationOnScreen();79robot.mouseMove(point.x + 20, point.y + 50);80robot.mouseMove(point.x + 30, point.y + 50);81robot.mousePress(InputEvent.BUTTON1_MASK);82robot.mouseRelease(InputEvent.BUTTON1_MASK);83}84}858687