-
Bug
-
Resolution: Won't Fix
-
P3
-
7u13
-
windows_7
FULL PRODUCT VERSION :
java version " 1.7.0_13 "
Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot(TM) Client VM (build 23.7-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Ubuntu 12.04.1 LTS
A DESCRIPTION OF THE PROBLEM :
Using the " GradientTranslucentWindowDemo " example from http://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html you can see the result of window translucency working. However, if you gradually decrease any of the color components (R, G, or B), the color compositing is incorrect.
isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT) report true.
Testing Windows 7, Vista and Mac OS X Mountain Lion; all work as expected.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Get the " GradientTranslucentWindowDemo " example from http://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html.
Change any of the color components of the gradient (final int R,G, or B) to something lower, i recommend 0 to see the full effect.
Run the app.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
You should see the color defined by R, G, and B with a gradient alpha value, starting at full transparent, and ending fully opaque.
On windows 7:
http://imageshack.us/photo/my-images/834/windows7s.png/
ACTUAL -
The background of the frame is the gradient color specified but is mixed with the desktop/background windows incorrectly.
On Ubuntu:
http://imageshack.us/photo/my-images/805/ubuntuw.png/
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import static java.awt.GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.GridBagLayout;
import java.awt.Paint;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
public class GradientTranslucentWindowDemo extends JFrame {
public GradientTranslucentWindowDemo() {
super( " GradientTranslucentWindow " );
setUndecorated(true);
setBackground(new Color(0,0,0,0));
setSize(new Dimension(300,200));
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
if (g instanceof Graphics2D) {
final int R = 0; // HERE IS THE ONLY CHANGE
final int G = 240;
final int B = 240;
Paint p =
new GradientPaint(0.0f, 0.0f, new Color(R, G, B, 0),
0.0f, getHeight(), new Color(R, G, B, 255), true);
Graphics2D g2d = (Graphics2D)g;
g2d.setPaint(p);
g2d.fillRect(0, 0, getWidth(), getHeight());
}
}
};
setContentPane(panel);
setLayout(new GridBagLayout());
add(new JButton( " I am a Button " ));
setAlwaysOnTop(true);
}
public static void main(String[] args) {
// Determine what the GraphicsDevice can support.
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
boolean isPerPixelTranslucencySupported =
gd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT);
//If translucent windows aren't supported, exit.
if (!isPerPixelTranslucencySupported) {
System.out.println(
" Per-pixel translucency is not supported " );
System.exit(0);
}
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ( " Nimbus " .equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception e) {
// If Nimbus is not available, you can set the GUI to another look and feel.
}
//JFrame.setDefaultLookAndFeelDecorated(true);
// Create the GUI on the event-dispatching thread
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
GradientTranslucentWindowDemo gtw = new GradientTranslucentWindowDemo();
// Display the window.
gtw.setVisible(true);
}
});
}
}
---------- END SOURCE ----------
java version " 1.7.0_13 "
Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot(TM) Client VM (build 23.7-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Ubuntu 12.04.1 LTS
A DESCRIPTION OF THE PROBLEM :
Using the " GradientTranslucentWindowDemo " example from http://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html you can see the result of window translucency working. However, if you gradually decrease any of the color components (R, G, or B), the color compositing is incorrect.
isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT) report true.
Testing Windows 7, Vista and Mac OS X Mountain Lion; all work as expected.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Get the " GradientTranslucentWindowDemo " example from http://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html.
Change any of the color components of the gradient (final int R,G, or B) to something lower, i recommend 0 to see the full effect.
Run the app.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
You should see the color defined by R, G, and B with a gradient alpha value, starting at full transparent, and ending fully opaque.
On windows 7:
http://imageshack.us/photo/my-images/834/windows7s.png/
ACTUAL -
The background of the frame is the gradient color specified but is mixed with the desktop/background windows incorrectly.
On Ubuntu:
http://imageshack.us/photo/my-images/805/ubuntuw.png/
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import static java.awt.GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.GridBagLayout;
import java.awt.Paint;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
public class GradientTranslucentWindowDemo extends JFrame {
public GradientTranslucentWindowDemo() {
super( " GradientTranslucentWindow " );
setUndecorated(true);
setBackground(new Color(0,0,0,0));
setSize(new Dimension(300,200));
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
if (g instanceof Graphics2D) {
final int R = 0; // HERE IS THE ONLY CHANGE
final int G = 240;
final int B = 240;
Paint p =
new GradientPaint(0.0f, 0.0f, new Color(R, G, B, 0),
0.0f, getHeight(), new Color(R, G, B, 255), true);
Graphics2D g2d = (Graphics2D)g;
g2d.setPaint(p);
g2d.fillRect(0, 0, getWidth(), getHeight());
}
}
};
setContentPane(panel);
setLayout(new GridBagLayout());
add(new JButton( " I am a Button " ));
setAlwaysOnTop(true);
}
public static void main(String[] args) {
// Determine what the GraphicsDevice can support.
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
boolean isPerPixelTranslucencySupported =
gd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT);
//If translucent windows aren't supported, exit.
if (!isPerPixelTranslucencySupported) {
System.out.println(
" Per-pixel translucency is not supported " );
System.exit(0);
}
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ( " Nimbus " .equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception e) {
// If Nimbus is not available, you can set the GUI to another look and feel.
}
//JFrame.setDefaultLookAndFeelDecorated(true);
// Create the GUI on the event-dispatching thread
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
GradientTranslucentWindowDemo gtw = new GradientTranslucentWindowDemo();
// Display the window.
gtw.setVisible(true);
}
});
}
}
---------- END SOURCE ----------
- relates to
-
JDK-8039345 Strange behaviour of per-pixel translucency on linux
- Resolved