JLabel withing another JLabel
Posted
by out_sider
on Stack Overflow
See other posts from Stack Overflow
or by out_sider
Published on 2010-05-05T23:39:23Z
Indexed on
2010/05/05
23:48 UTC
Read the original article
Hit count: 340
java
|game-development
I want to do a very simple thing with java swing and I'm not being able to.
I added a jLabel as it is the only object using java swing that can hold an image (using the icon property)...at least I wasn't able to set an image using other objects.
Now I want to add another jlabel in top of the first one with another image so it can be "clicked" independently from the "background" label. But whenever I try to add it using the graphical editor or by doing jLabel1.add(jLabel2) it doesn't work...it simply sets next to the label1 but not on top of it.
This is in order to do a java application like the Tic Tac Toe game...so I can have the background which are squares (first label) and the others the "X" and "O".
This might be the board and I want to put labels on each square so they can be the pieces.
© Stack Overflow or respective owner