jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 23010 6dadb192ad81
child 43088 85643a015b5a
permissions -rw-r--r--
8159690: [TESTBUG] Mark headful tests with @key headful. Reviewed-by: simonis, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11094
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
     1
/*
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 23010
diff changeset
     2
 * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
11094
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
     4
 *
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
     8
 *
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    13
 * accompanied this code).
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    14
 *
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    18
 *
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    21
 * questions.
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    22
 */
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    23
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    24
/*
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    25
 * @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 23010
diff changeset
    26
 * @key headful
11094
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    27
 * @bug 7108598
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    28
 * @summary Container.paint/KeyboardFocusManager.clearMostRecentFocusOwner methods deadlock
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    29
 * @library ../../regtesthelpers
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    30
 * @author Oleg Pekhovskiy
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    31
 * @build Util
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    32
 * @run main/timeout=20 PaintSetEnabledDeadlock
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    33
 */
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    34
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    35
import java.awt.*;
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    36
import java.awt.event.*;
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    37
import test.java.awt.regtesthelpers.Util;
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    38
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    39
public class PaintSetEnabledDeadlock extends Frame {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    40
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    41
    final TestPanel panel;
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    42
    final Button button;
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    43
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    44
    public static void main(String[] args) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    45
        PaintSetEnabledDeadlock frame = new PaintSetEnabledDeadlock();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    46
        frame.setSize(200, 200);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    47
        frame.setVisible(true);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    48
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    49
        Robot robot = Util.createRobot();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    50
        robot.setAutoDelay(100);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    51
        robot.setAutoWaitForIdle(true);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    52
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    53
        for (int i = 0; i < 20; ++i) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    54
            Util.clickOnComp(frame.panel, robot);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    55
            Util.clickOnComp(frame.button, robot);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    56
        }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    57
11817
433d7f4ea51d 7143070: test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java freezes on exit
bagiras
parents: 11094
diff changeset
    58
        boolean ret = frame.panel.stop();
11094
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    59
        frame.dispose();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    60
11817
433d7f4ea51d 7143070: test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java freezes on exit
bagiras
parents: 11094
diff changeset
    61
        if (!ret) {
433d7f4ea51d 7143070: test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java freezes on exit
bagiras
parents: 11094
diff changeset
    62
            throw new RuntimeException("Test failed!");
433d7f4ea51d 7143070: test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java freezes on exit
bagiras
parents: 11094
diff changeset
    63
        }
11094
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    64
        System.out.println("Test passed.");
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    65
    }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    66
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    67
    public PaintSetEnabledDeadlock() {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    68
        super("7108598 test");
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    69
        setLayout(new GridLayout(1, 2));
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    70
        addWindowListener(new WindowAdapter() {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    71
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    72
            @Override
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    73
            public void windowClosing(WindowEvent e) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    74
                panel.stop();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    75
                System.exit(0);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    76
            }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    77
        });
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    78
        panel = new TestPanel();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    79
        add(panel);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    80
        button = new Button("Enable");
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    81
        button.addMouseListener(new MouseAdapter() {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    82
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    83
            @Override
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    84
            public void mousePressed(MouseEvent e) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    85
                panel.setEnabled(true);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    86
                panel.sync();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    87
                panel.repaint();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    88
            }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    89
        });
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    90
        add(button);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    91
    }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    92
}
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    93
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    94
class TestPanel extends Panel implements Runnable {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    95
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    96
    Image image = null;
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    97
    Thread thread = null;
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    98
    volatile boolean active = true;
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
    99
    final Object sync = new Object();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   100
    Panel panel = this;
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   101
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   102
    public TestPanel() {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   103
        addMouseListener(new MouseAdapter() {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   104
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   105
            @Override
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   106
            public void mouseReleased(MouseEvent e) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   107
                synchronized (panel) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   108
                    sync();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   109
                    panel.setEnabled(false);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   110
                }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   111
                panel.repaint();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   112
            }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   113
        });
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   114
        thread = new Thread(this);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   115
        thread.start();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   116
    }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   117
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   118
    @Override
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   119
    public void paint(Graphics paramGraphics) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   120
        synchronized (getTreeLock()) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   121
            Rectangle rect = getBounds();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   122
            if (image == null) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   123
                image = createImage(rect.width, rect.height);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   124
            }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   125
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   126
            if (image != null) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   127
                paramGraphics.drawImage(image, 0, 0, this);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   128
            }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   129
        }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   130
    }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   131
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   132
    @Override
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   133
    public void run() {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   134
        while (active) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   135
            try {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   136
                synchronized (sync) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   137
                    sync.wait();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   138
                }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   139
            } catch (InterruptedException ex) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   140
            }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   141
            if (active) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   142
                draw();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   143
            }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   144
        }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   145
    }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   146
11817
433d7f4ea51d 7143070: test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java freezes on exit
bagiras
parents: 11094
diff changeset
   147
    public boolean stop() {
11094
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   148
        active = false;
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   149
        try {
11817
433d7f4ea51d 7143070: test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java freezes on exit
bagiras
parents: 11094
diff changeset
   150
            sync();
433d7f4ea51d 7143070: test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java freezes on exit
bagiras
parents: 11094
diff changeset
   151
            thread.join(1000);
433d7f4ea51d 7143070: test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java freezes on exit
bagiras
parents: 11094
diff changeset
   152
            if (thread.isAlive()) {
433d7f4ea51d 7143070: test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java freezes on exit
bagiras
parents: 11094
diff changeset
   153
                thread.interrupt();
433d7f4ea51d 7143070: test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java freezes on exit
bagiras
parents: 11094
diff changeset
   154
                return false;
11094
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   155
            }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   156
        } catch (InterruptedException ex) {
11817
433d7f4ea51d 7143070: test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java freezes on exit
bagiras
parents: 11094
diff changeset
   157
            return false;
11094
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   158
        }
11817
433d7f4ea51d 7143070: test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java freezes on exit
bagiras
parents: 11094
diff changeset
   159
        return true;
11094
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   160
    }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   161
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   162
    public void draw() {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   163
        synchronized (getTreeLock()) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   164
            if (image != null) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   165
                Graphics localGraphics = image.getGraphics();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   166
                Dimension size = getSize();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   167
                localGraphics.setColor(isEnabled() ? Color.green : Color.red);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   168
                localGraphics.fillRect(0, 0, size.width, size.height);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   169
                super.paint(localGraphics);
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   170
                localGraphics.dispose();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   171
                getTreeLock().notifyAll();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   172
            }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   173
        }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   174
    }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   175
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   176
    public void sync() {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   177
        synchronized (sync) {
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   178
            sync.notify();
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   179
        }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   180
    }
1f244f2719d3 7108598: Pogo Table Games freeze with JDK 7
bagiras
parents:
diff changeset
   181
}