| Author |
JLabel on top of JLabel
|
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15229
|
|
I have a JPanel that I am adding JLabels onto that contain an ImageIcon. There are times when I need to place a new JLabel on top of another JLabel but without removing one. The one I place on top always get's placed underneath the first JLabel. I have tried Integer.MAX_VALUE and Integer.MIN_VALUE but it isn't working. Any ideas? ------------------ Happy Coding, Gregg Bolinger
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15229
|
|
Still waiting to see if anyone knows the answer to this. If you do, please reply. It would be greatly appriciated. Thanks ------------------ Happy Coding, Gregg Bolinger
|
 |
Vinod Venugopal
Ranch Hand
Joined: Dec 06, 2000
Posts: 148
|
|
Hi Greg, Even im trying to to get a soln this problem, I know its too late, but I found ur messg using the Search option, I'm using labels with images, & the new label gets added below the first one..any ideas?
|
- Vinod<br />-------<br />SCJP2
|
 |
Peter Phung
Ranch Hand
Joined: Dec 06, 2001
Posts: 138
|
|
Why do u try to add one label on top of another label? wouldn't it be easier to just change the icon and the text in the label?
|
Pete<br />"Reality is an illusion <br />brought on by a lack of <br />drink, drugs and smut"
|
 |
Sayed Ibrahim Hashimi
Ranch Hand
Joined: May 17, 2001
Posts: 148
|
|
I'm not really sure if this will help you but cant you use CardLayout to display different Components. Bascially if you want to display 3 different sets of Components then you will create 3 "Cards". These cards can take the same space in a Component but only one will be displayed. So if you want to have a label on top of another then create different "Cards" and display the one you want. Hope this helps.
|
SCJP 1.4<br /><a href="http://www.cise.ufl.edu/~sih" target="_blank" rel="nofollow">www.cise.ufl.edu/~sih</a>
|
 |
Vinod Venugopal
Ranch Hand
Joined: Dec 06, 2000
Posts: 148
|
|
No guys, What I want to do is display a component over a component..its like a chair over a floor, i need to display the floor as well as the chair, but with JLabels having an image,the chair goes under the floor..hope u all get the idea
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15229
|
|
|
My whole reasoning was for cards layed out over each other but cascading.
|
 |
Peter Phung
Ranch Hand
Joined: Dec 06, 2001
Posts: 138
|
|
In my limited experience with Java, it is not possible to display one component on top of another in the same panel/container. I believe it is possible to place the two components into two panels and switch between the panels using cardlayout. I hope this helps.
|
 |
Nathan Pruett
Bartender
Joined: Oct 18, 2000
Posts: 4121
|
|
Look at the JLayeredPane API... it was made for just this kind of thing... run the example code below to see a JLayeredPane in action... -Nate
|
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
|
 |
 |
|
|
subject: JLabel on top of JLabel
|
|
|