JFrame's opacity affects all painted image's opacity in a JPanel
Code :
import javax.swing.*;
import java.awt.*;
public class Frame {
public Frame() {
setUpWindow();
}
public void setUpWindow() {
JFrame f = new JFrame();
Panel p = new Panel();
f.add(p);
f.setUndecorated(true);
f.setOpacity(.5f);
f.setSize(400, 500);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
private class Panel extends JPanel {
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.RED);
g2d.fillRect(10, 10, 100, 100);
}
}
public static void main(String[] args) {
new Frame();
}
}
i was looking for a way to create an Undecorated Frame with an Invisble Panel(got that by the Frame's opacity) but it affects all the images that i draw in the JPanel, (i just used a filled rect here to represent an image drawn in panel), i need to retain the opacity of the Images, frame and Panels should be invisible.. there are tons of codes and articles on net, that floods me again.. need help again please..
,it affects all the opacity of object in it..
Re: JFrame's opacity affects all painted image's opacity in a JPanel
Re: JFrame's opacity affects all painted image's opacity in a JPanel
Quote:
Oooh fancy, Java 7 stuff!
:o , so the current platform does really have a big impact on developers, i just downloaded the current version, and see some new stuffs, and it sounds like the transparency features been efficiently handled on 7, (i just take things for granted :">), thanks but i already see that link, even the JLayer tutorial that shows how to manipulate some window effects and some listeners ,
but the problem is when the JFrame's opacity has been manipulated, all the component that it handles is also affected by the opacity (even jpg/png images), even the buttons that is shown on that link is transparent.
i searched and focus on containers generally on JPanels, until i found some articles that states that JPanels only control a particular color scheme which is RGB, not ARGB(does 'A' stands for alpha?), they say that JPanel's doesnt capable of manipulating its own alpha to reduce opacity, even the Robot approach that captures the background(.createScreenCapture()) that makes the JPanel look invisible, but it seems fancy to that one, my goal is to create a customized shaped frame(already done), transparent window(already done), but i need to maintain the opacity of the images or any components(buttons, etc...) inside the container(JFrame or JPanel), how can i do this? is there any resource out there that might be useful to implement this kind of approach? , i've been asking my friend google too much, but it seems like its impossible to look for some guidelines for this one..