0

enter image description here

enter image description here

enter image description here

Okey I have a class that prints the board and another class that prints the Chess

how do I use the LayeredPane to merge them together like the example picture above? I been trying all day and nothing seems to work at all. I am using JFrame to print the picture.

kleopatra
51.7k28 gold badges103 silver badges220 bronze badges
asked Nov 5, 2011 at 8:29
1

2 Answers 2

1

Your question doesn't tell us much about the structure of your program or the specific problem that you're having. I assume that you've gone through the JLayeredPane tutorial which should explain to you pretty much the workings of a JLayeredPane, and that you understand it fully, otherwise I assume that you'd ask for clarification for your points of confusion in your question above.

I've outlined one way that I've approached a similar project in this answer: does-adding-a-jlabel-to-a-jpanel-hide-the-jpanel. Please check it out and again review the Swing tutorial and ask if anything doesn't make sense.

answered Nov 5, 2011 at 10:38
Sign up to request clarification or add additional context in comments.

Comments

1

You should print the chess and the board in the same paintComponent() method. So print them in the same class. You could use something like:

public void paintComponent(Graphics g) {
 printBoard(g);
 printChess(g);
}
answered Nov 5, 2011 at 8:47

4 Comments

as a requirement i have to do them in sperate classes or I would , it makes it a lot easer
@ricedragon: it makes it harder.
thats why i am asking , I have no freaking clue at all , because if i add the two object in the Jfame the ChessPiece will overwrite the Board
same z-index? or opaque set to true? See download.oracle.com/javase/tutorial/uiswing/components/… for more information

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.