author | stefank |
Mon, 04 Apr 2016 09:15:01 +0200 | |
changeset 37241 | b9961c99c356 |
parent 29510 | 9c567246bdae |
permissions | -rw-r--r-- |
29510
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
1 |
/* |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
4 |
* |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
8 |
* |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
13 |
* accompanied this code). |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
14 |
* |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
18 |
* |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
21 |
* questions. |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
22 |
*/ |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
23 |
|
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
24 |
import java.awt.Color; |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
25 |
import java.awt.FlowLayout; |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
26 |
import javax.swing.JButton; |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
27 |
import javax.swing.JCheckBox; |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
28 |
import javax.swing.JFrame; |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
29 |
import javax.swing.SwingUtilities; |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
30 |
import java.awt.Component; |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
31 |
import javax.swing.JOptionPane; |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
32 |
|
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
33 |
/** |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
34 |
* @test |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
35 |
* @bug 8039345 |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
36 |
* @author Prasanta Sadhukhan |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
37 |
* @run main/manual ComponentResizeTest |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
38 |
* @summary Resizes JFrame so that component drawn inside it gets repainted |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
39 |
* without leaving any trails |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
40 |
*/ |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
41 |
public class ComponentResizeTest { |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
42 |
|
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
43 |
private static JFrame demoFrame; |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
44 |
|
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
45 |
public static void testresize() throws Exception { |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
46 |
Thread.sleep(5000); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
47 |
for (int i = 0; i < 20; i++) { |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
48 |
SwingUtilities.invokeLater(() -> { |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
49 |
demoFrame.setSize(demoFrame.getWidth() + 5, demoFrame.getHeight() + 5); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
50 |
}); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
51 |
Thread.sleep(1000); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
52 |
} |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
53 |
} |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
54 |
|
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
55 |
public static void main(String[] args) throws Exception { |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
56 |
SwingUtilities.invokeAndWait(() -> { |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
57 |
JOptionPane.showMessageDialog( |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
58 |
(Component) null, |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
59 |
"The test creates a transparent JFrame and resizes the JFrame. Please verify JFrame is transparent and components (like JButton, checkbox) move without leaving any trails", |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
60 |
"information", JOptionPane.INFORMATION_MESSAGE); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
61 |
createAndShowGUI(); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
62 |
}); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
63 |
|
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
64 |
try { |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
65 |
testresize(); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
66 |
} finally { |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
67 |
SwingUtilities.invokeLater(() -> { |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
68 |
demoFrame.dispose(); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
69 |
}); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
70 |
} |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
71 |
|
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
72 |
SwingUtilities.invokeAndWait(() -> { |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
73 |
int confirm = JOptionPane.showConfirmDialog( |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
74 |
(Component) null, |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
75 |
"Did the component resize work without leaving any trails?", |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
76 |
"alert", JOptionPane.YES_NO_OPTION); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
77 |
if (confirm == JOptionPane.YES_OPTION) { |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
78 |
System.out.println("Test passed"); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
79 |
} else { |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
80 |
System.out.println("Test failed"); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
81 |
throw new RuntimeException("Component resize leaves trail"); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
82 |
} |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
83 |
}); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
84 |
} |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
85 |
|
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
86 |
private static void createAndShowGUI() { |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
87 |
demoFrame = new JFrame(); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
88 |
demoFrame.setSize(300, 300); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
89 |
demoFrame.setLayout(new FlowLayout()); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
90 |
demoFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
91 |
demoFrame.setUndecorated(true); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
92 |
demoFrame.setBackground(new Color(0f, 0, 0, 0.1f)); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
93 |
JCheckBox b = new JCheckBox("Whatever"); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
94 |
demoFrame.paintAll(null); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
95 |
b.setOpaque(true); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
96 |
demoFrame.add(b); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
97 |
demoFrame.add(new JButton()); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
98 |
demoFrame.setVisible(true); |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
99 |
} |
9c567246bdae
8039345: Strange behaviour of per-pixel translucency on linux
serb
parents:
diff
changeset
|
100 |
} |