• Post Reply Bookmark Topic Watch Topic
  • New Topic

To make JLabel move

 
maja neskovic
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! I'm making an applet using Swing and I have one JPanel on my JApplet. JApplet has slider whose moving makes drawn shape on JPanel to move. I would like to put text on that shape and make them move together when I move slider. I tried using JLabel, but i don't know how to make it move. I messed with gap settings, invoked slider.getValue() in .addGap, but it doesn't work.

Any ideas...?

Greetings!
 
Mahesh Kedari
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check this post.
 
maja neskovic
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I have looked at this post, but I got lost here. I don't have pack() and I need to make JLabel moving synchronously with JSlider. Is there any way to do that?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Graphics object used to draw the shape also has a method called drawString() which you can use to draw your text
 
maja neskovic
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh God! I totally forget on drawString and got stacked with labels. Nonsense...

Everything works just fine now. Thank you a lot, my friend!

Greetings!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!