-
Bug
-
Resolution: Fixed
-
P3
-
6
-
b77
-
x86
-
windows_xp
/*
If you run this app with the attached PNG image ("test.png") in
the same directory you'll see that the lightbulb image's background
is white - not transparent. However viewing the same image with
Microsoft's tools shows that the image has a transparent background.
As well it should, since it was saved that way using IrFanView 3.98,
a freeware image editor.
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Test {
JFrame mainFrame = null;
void initialize(String[] ignore) {
Icon icon = new ImageIcon("test.png");
mainFrame = new JFrame("Image should have transparent background");
Container cp = mainFrame.getContentPane();
cp.setBackground(Color.green);
mainFrame.add(new JLabel(icon));
}
void show() {
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.pack();
mainFrame.setVisible(true);
}
public static void main(final String[] args) throws Exception {
Runnable doCreateAndShowGUI = new Runnable() {
public void run() {
try {
Test app = new Test();
app.initialize(args);
app.show();
}
catch (Exception e) {
// TBD log an error
}
}
};
SwingUtilities.invokeLater(doCreateAndShowGUI);
}
}
If you run this app with the attached PNG image ("test.png") in
the same directory you'll see that the lightbulb image's background
is white - not transparent. However viewing the same image with
Microsoft's tools shows that the image has a transparent background.
As well it should, since it was saved that way using IrFanView 3.98,
a freeware image editor.
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Test {
JFrame mainFrame = null;
void initialize(String[] ignore) {
Icon icon = new ImageIcon("test.png");
mainFrame = new JFrame("Image should have transparent background");
Container cp = mainFrame.getContentPane();
cp.setBackground(Color.green);
mainFrame.add(new JLabel(icon));
}
void show() {
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.pack();
mainFrame.setVisible(true);
}
public static void main(final String[] args) throws Exception {
Runnable doCreateAndShowGUI = new Runnable() {
public void run() {
try {
Test app = new Test();
app.initialize(args);
app.show();
}
catch (Exception e) {
// TBD log an error
}
}
};
SwingUtilities.invokeLater(doCreateAndShowGUI);
}
}
- relates to
-
JDK-4307550 PNG Transparency ignored
- Closed