I was trying to have a image background, so I created the following code in a JFrame:
@Override
public void paint(Graphics g) {
super.paint(g);
try {
final Image image = ImageIO.read(getClass().getResource("/images/login/gentlenoise100.png"));
int iw = 256;
int ih = 256;
for (int x = 0; x < getWidth(); x += iw) {
for (int y = 0; y < getHeight(); y += ih) {
g.drawImage(image, x, y, iw, ih, this);
}
}
} catch (IOException ex) {
Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
}
for(Component componente:getComponents()){
componente.repaint();
}
}
I saw that the background color had some kind of preference and I decided so set it to invisible:
setBackground(new java.awt.Color(0,0,0,0));
It was working fine in Mac OS X (java 1.6), and I had to probe it in Windows and if I remove the setBackground call it doesn't show my background, if I keep the background color invisible it throws an exception and says the Frame is decorated!
I tried to use setUndecorate(true)
but in macosx it looses the title bar (of course) and in Windows it gives me a transparent window.
How can I solve that?