Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Paint/CheckboxRepaint.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.*;24import java.awt.peer.CheckboxPeer;2526/**27* @test28* @bug 709042429* @author Sergey Bylokhov30*/31public final class CheckboxRepaint extends Checkbox {3233public static void main(final String[] args) {34for (int i = 0; i < 10; ++i) {35final Frame frame = new Frame();36frame.setSize(300, 300);37frame.setLocationRelativeTo(null);38CheckboxRepaint checkbox = new CheckboxRepaint();39frame.add(checkbox);40frame.setVisible(true);41sleep();42checkbox.test();43frame.dispose();44}45}4647private static void sleep() {48try {49Thread.sleep(2000);50} catch (InterruptedException ignored) {51}52}5354@Override55public void paint(final Graphics g) {56super.paint(g);57if (!EventQueue.isDispatchThread()) {58throw new RuntimeException("Wrong thread");59}60test();61}6263void test() {64setState(getState());65((CheckboxPeer) getPeer()).setState(getState());6667setCheckboxGroup(getCheckboxGroup());68((CheckboxPeer) getPeer()).setCheckboxGroup(getCheckboxGroup());6970setLabel("");71setLabel(null);72setLabel(getLabel());73((CheckboxPeer) getPeer()).setLabel("");74((CheckboxPeer) getPeer()).setLabel(null);75((CheckboxPeer) getPeer()).setLabel(getLabel());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