Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Paint/LabelRepaint.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.Label;27import java.awt.peer.LabelPeer;2829/**30* @test31* @bug 709042432* @author Sergey Bylokhov33*/34public final class LabelRepaint extends Label {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);41LabelRepaint label = new LabelRepaint();42frame.add(label);43frame.setVisible(true);44sleep();45label.test();46frame.dispose();47}48}4950private static void sleep() {51try {52Thread.sleep(2000);53} catch (InterruptedException ignored) {54}55}5657@Override58public void paint(final Graphics g) {59super.paint(g);60if (!EventQueue.isDispatchThread()) {61throw new RuntimeException("Wrong thread");62}63test();64}6566void test() {67setAlignment(getAlignment());68((LabelPeer) getPeer()).setAlignment(getAlignment());6970setText("");71setText(null);72setText(getText());73((LabelPeer) getPeer()).setText("");74((LabelPeer) getPeer()).setText(null);75((LabelPeer) getPeer()).setText(getText());7677setFont(null);78setFont(getFont());79getPeer().setFont(getFont());8081setBackground(null);82setBackground(getBackground());83getPeer().setBackground(getBackground());8485setForeground(null);86setForeground(getForeground());87getPeer().setForeground(getForeground());8889setEnabled(isEnabled());90getPeer().setEnabled(isEnabled());91}92}939495