• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transparent Panel on top of Panel?

 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm creating a chess board, and I want to be able to display the chess pieces (.gif's) on the squares. I'm extending a JPanel and drawing all the squares. Is there a way to create a transparent panel on top of that panel so I'll be able to use the chessboard as the background and align the pieces in the correct locations? Any suggestions would help thanks.
 
Ajay Singhal
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i have the same problem of showing transparent panel on top of the panel.Actually i want to perform some drawing operations on top of the html pane.
if you come across any solution then kindly give me the solution.
you can mail me at Ajay_k_singhal@yahoo.com
Thanx
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you call setOpaque( false ) on the upper panel you will be able to see the panel under it...

-Nate
 
Terry Stehle
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im currently working on a chess program. Anyways I just created a custom panel and overriden the painComponent method. Something like this
public class BoardPanel extends JPanel{
public void paintComponent(Graphics g){
super.paintComponent(g);
g.drawImage(Board,0,0,this);
//Add for loop to draw image for each square
g.drawImage(Piece[Col][Row],add math to align piece x, and y);
}

}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic