This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes draw rect problem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

draw rect problem?

nick cheng
Greenhorn

Joined: Oct 31, 2004
Posts: 11
public void paint(Graphics g) {
if (!buffered){
buffer = createImage(50, 50);
bufferG=buffer.getGraphics();

buffered=true;
}
bufferG.setColor(Color.RED);

bufferG.drawRect(0, 0, (int) imageSize.getWidth(),
(int) imageSize.getHeight());
g.drawImage(buffer,100,100,this);
}

in this Applet file ,i set the background colour is "black" in void init()
,then i set some images one the surface,and last i use double buffer draw a rect image,but when i draw the image,the rect become ,a black solid rect ,how to make it become tranparent?
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
You should be using the Graphics2D class and the AlphaComposite class. See this Tutorial
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Don't post the same question to more than one forum -- it just wastes people's time and makes them less likely to help you. I'm closing this and leaving the one in the correct forum -- the Swing/AWT copy -- open. I've taken the liberty of deleting the other copies for you.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: draw rect problem?