Link to home
Start Free TrialLog in
Avatar of mwalker
mwalkerFlag for United States of America

asked on

Vertical scrolling using Graphics2D help needed.

Has anyone had any experience in doing vertical scrolling using Graphics2D.  Basically I need to create a vertical scrolling "widget" that I can use in Swing applets.  I'd like just to be able to pass it a String and the widget will display the text, scrolling the previous text up if necessary.

I have created a component that will do this with a JList inside a JScrollPane.  However, there is a large amount of data that currently is being received (via JMS) by my applet and I noticed that by scrolling using my current method (i.e. calling the method ensureIndexIsVisible() on the scrollpane) is processor intensive. Also, I have noticed that it is even more processor intensive if I turn on BACKINGSTORE_SCROLL_MODE in the viewport of the JScrollPane.  Hence, I thought that Graphics2D may be a better approach.

I'd appreciate it if someone could either point me to a link that will give me an example of how to do this or respond with an example of their own.

Thanks in advance for your help.
Avatar of heyhey_
heyhey_

if nobody else responds to your problem, I will post some code tomorrow (have to go now)

have a nice eveneing :)
Avatar of mwalker

ASKER

Thanks heyhey.  I will appreciate it.
Avatar of Mick Barry
Just create an offscreen image of what you want to display and 'move' it up the screen.
do you want all the "old" info to be visible after scrolling ?
Avatar of mwalker

ASKER

objects: I'm not experienced with drawing in Java.  So, I'm not exactly sure what you mean by an offscreen image.  I also don't know how to "move it up", which is why I posted this question.

heyhey: I do not need the either the "old" info to be visible or accessible after scrolling.
so you need custom component that displays several rows of text and when new text is appened the old one scroll up (and possible disappear) ?
Avatar of mwalker

ASKER

You are exactly correct.  If you can show me a simple subclass of JPanel that uses Graphics2D for displaying the text and scrolls up (and possibly disappears), I can add more stuff as I need it (e.g. rendering lines in different colors based on the data sent to it).

Thanks.
sorry, I was very busy these last few days, I will try to post some sample code during the weekend.
ASKER CERTIFIED SOLUTION
Avatar of heyhey_
heyhey_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
any news ?
Avatar of mwalker

ASKER

heyhey: This is exactly what I needed. Thanks so much.