How can i make AWT component transparent when the background is progressive image?
Note: AWT used only, where progressive Window() 5 frames/per second. Panel() is not getting transparent now while using new Color(255,0,0,0). How to make the panel transparent?
AWT? here:
public class 888 extends Window
{
private Button button;
public 888()
{
super(new Frame());
// Transparent failed
getOwner().setBackground(new Color(255, 0, 0, 0) );
this.setLayout (new BorderLayout ());
button = new Button("close");
button.setBackground(Color.RED);
button.setSize(200,200);
button.setLocation(0,20);
this.add("North", button);
Panel p = new Panel();
//p.setOpaque(false);
p.setSize(200,200);
p.setLocation(400,400);
// Transparent failed
p.setBackground(new Color(255,0,0,0));
p.add("Left", new Button("Test"));
this.add("North", p);
//AWTUtilities.setWindowOpacity(this, 0.2f); // Error in Linux
}
public static void main(String[] args)
{
Window j = new 888();
j.setVisible(true);
//j.setBackground( new Color(255, 0, 0, 0) );
}
}
SWing?: here
public class 888 extends JWindow
{
private JButton button;
public 888()
{
//super(new Frame());
// Transparent failed
getOwner().setBackground(new Color(255, 0, 0, 0) );
this.setLayout (new BorderLayout ());
button = new JButton("close");
button.setBackground(new Color(255,0,0,255));
button.setSize(200,200);
button.setLocation(0,20);
this.add("North", button);
JPanel p = new JPanel();
//p.setOpaque(false);
p.setSize(200,200);
p.setLocation(400,400);
// Transparent failed
p.setBackground(new Color(255,0,0,0));
p.add("Left", new Button("Test"));
this.add("North", p);
//AWTUtilities.setWindowOpacity(this, 0.2f); // Error in Linux
}
public static void main(String[] args)
{
JWindow j = new 888();
j.setVisible(true);
//j.setBackground( new Color(255, 0, 0, 0) );
}
}
Note: None really works, with Swing i have problem with JButton, because when the JWindow get refreshed the JButton become invisible. With AWT when i use Button and Panel then none can set its transparency.
How do i solve it? For progressive background image Panel or Button to make transparent?
Summary:
I came to a point now after doing many tests, which is not available anywhere else. Mostly in a progressive scan Window() or JWindow(). You better use Awt for (no transparent objects), and Swing for (transparent objects). Do not make a conclusion like many not to use Awt and Swing, you have to be smart to mix it, else gonna end up with endless summer of 69 :)
Reference:
http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html http://java.sun.com/products/jfc/tsc/articles/threads/threads3.html