mwalker
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.
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.
ASKER
Thanks heyhey. I will appreciate it.
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 ?
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.
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) ?
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.
Thanks.
sorry, I was very busy these last few days, I will try to post some sample code during the weekend.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
any news ?
ASKER
heyhey: This is exactly what I needed. Thanks so much.
have a nice eveneing :)