jdk/test/javax/swing/JFrame/HangNonVolatileBuffer/HangNonVolatileBuffer.java
author goetz
Tue, 09 Dec 2014 11:57:46 +0100
changeset 28187 fc19df82d6ee
parent 25195 9de77f5b0df2
child 40128 e635645d2a8a
permissions -rw-r--r--
8066964: ppc64: argument and return type profiling, fix problem with popframe Reviewed-by: roland, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25195
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     1
/*
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     4
 *
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     8
 *
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    13
 * accompanied this code).
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    14
 *
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    18
 *
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    21
 * questions.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    22
 */
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    23
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    24
import java.lang.reflect.InvocationTargetException;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    25
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    26
import javax.swing.JFrame;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    27
import javax.swing.SwingUtilities;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    28
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    29
/**
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    30
 * @test
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    31
 * @bug 8029455
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    32
 * @summary Swing should not hang if non-volatile image is used as a backbuffer.
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    33
 * @run main/othervm -Dswing.volatileImageBufferEnabled=false HangNonVolatileBuffer
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    34
 */
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    35
public final class HangNonVolatileBuffer {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    36
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    37
    private static JFrame f;
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    38
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    39
    public static void main(final String[] args)
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    40
            throws InvocationTargetException, InterruptedException {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    41
        SwingUtilities.invokeAndWait(() -> {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    42
            f = new JFrame("JFrame");
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    43
            f.setSize(300, 300);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    44
            f.setLocationRelativeTo(null);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    45
            f.setVisible(true);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    46
        });
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    47
        SwingUtilities.invokeAndWait(() -> {
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    48
            // flush the EDT
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    49
        });
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    50
        Thread.sleep(1000);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    51
        SwingUtilities.invokeAndWait(f::dispose);
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    52
    }
9de77f5b0df2 8029455: [JLightweightFrame] support scaled painting
serb
parents:
diff changeset
    53
}