Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Paint/ListRepaint.java
47490 views
/*1* Copyright (c) 2013, 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*/2223import java.awt.EventQueue;24import java.awt.Frame;25import java.awt.Graphics;26import java.awt.List;27import java.awt.peer.ListPeer;2829/**30* @test31* @bug 709042432* @author Sergey Bylokhov33*/34public final class ListRepaint extends List {3536public static void main(final String[] args) {37for (int i = 0; i < 10; ++i) {38final Frame frame = new Frame();39frame.setSize(300, 300);40frame.setLocationRelativeTo(null);41ListRepaint list = new ListRepaint();42list.add("1");43list.add("2");44list.add("3");45list.add("4");46list.select(0);47frame.add(list);48frame.setVisible(true);49sleep();50list.test();51frame.dispose();52}53}5455private static void sleep() {56try {57Thread.sleep(2000);58} catch (InterruptedException ignored) {59}60}6162@Override63public void paint(final Graphics g) {64super.paint(g);65if (!EventQueue.isDispatchThread()) {66throw new RuntimeException("Wrong thread");67}68test();69}7071void test() {72select(0);73((ListPeer) getPeer()).select(getSelectedIndex());7475setFont(null);76setFont(getFont());77getPeer().setFont(getFont());7879setBackground(null);80setBackground(getBackground());81getPeer().setBackground(getBackground());8283setForeground(null);84setForeground(getForeground());85getPeer().setForeground(getForeground());8687setEnabled(isEnabled());88getPeer().setEnabled(isEnabled());89}90}919293