Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Paint/ButtonRepaint.java
47525 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*/222324import java.awt.*;25import java.awt.peer.ButtonPeer;2627/**28* @test29* @bug 709042430* @author Sergey Bylokhov31*/32public final class ButtonRepaint extends Button {3334public static void main(final String[] args) {35for (int i = 0; i < 10; ++i) {36final Frame frame = new Frame();37frame.setSize(300, 300);38frame.setLocationRelativeTo(null);39ButtonRepaint button = new ButtonRepaint();40frame.add(button);41frame.setVisible(true);42sleep();43button.test();44frame.dispose();45}46}4748private static void sleep() {49try {50Thread.sleep(2000);51} catch (InterruptedException ignored) {52}53}5455@Override56public void paint(final Graphics g) {57super.paint(g);58if (!EventQueue.isDispatchThread()) {59throw new RuntimeException("Wrong thread");60}61test();62}6364void test() {65setLabel("");66setLabel(null);67setLabel(getLabel());68((ButtonPeer) getPeer()).setLabel("");69((ButtonPeer) getPeer()).setLabel(null);70((ButtonPeer) getPeer()).setLabel(getLabel());7172setFont(null);73setFont(getFont());74getPeer().setFont(getFont());7576setBackground(null);77setBackground(getBackground());78getPeer().setBackground(getBackground());7980setForeground(null);81setForeground(getForeground());82getPeer().setForeground(getForeground());8384setEnabled(isEnabled());85getPeer().setEnabled(isEnabled());86}87}888990