I need some auto loop-scrolling (marquee text) it's contents JPanel
. It contents must react on mouse clicking on different elements. So just drawing contents with moved coordinates not working here, because real position of elements not changing.
Also it must be update able. Most likely that it will be smooth update - without any bouncing.
Tried to use JScrollPane
with no visible scrollers and auto-scrolling, it can hold action listeners, but I can't make it smooth looping and smooth updating contents.
UPDATE it should looks like this:
http://h1.flashvortex.com/display.php?id=2_1311593920_25605_144_0_700_30_6_1_92
but with modifying contents from code, without stopping animation and bouncing.
MarqueePanel includes
start()
andstop()
methods; it might make a useful starting point, but you'll have to factor out anupdate()
method.Addendum: As the example uses a
JLabel
, it cannot be edited in situ. If using aJTextField
, it may be easiest to update the corresponding model,Document
.You might be able to use the Marquee Panel. The code uses real components so you should be able to add and react to any listener you add to the components.
Edit:
Oops, I don't know what I was thinking, my code uses the Graphics.translate(...) method to paint the components so using a MouseListener directly won't work.
Edit2:
Maybe the following code will help. Just add the method to the MarqueePanel class:
Now you can add a MouseListener to the MarqueePanel and then invoke this method in order to determine which component the MouseEvent was generated for. Once you know which component was clicked you will manually need to invoke an Action for that component. Or you could try redispatching the MouseEvent to the component. You wouuld need to recreate the MouseEvent to make the component the source of the event instead of the panel being the source. You would also need to covert the event X/Y locations to be relative to the component and not the panel. The SwingUtils class should help with this.