# [java] TV Scroller

This topic is 4872 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello everyone Im posting this in the hope someone could help me out, knowing that there must be so much better programmers here that I am... Have you ever seen those TV shows where you send a cellphone message (SMS or whatever) and it shows in the screen in a scroller (you know, messages like hello mum, or cheers from england and so on...). Ok, Im building an exact application like that... So far I have it up and running, I dont post a cool screenshot with a background video and the scroll running in the inferior part of the screen, because all I get is a black screen from the video when I take the screenshot (I used to know how to make it right, but I must have forgotten). Anyway, the point is, this application is supossed (well, I want it to) to load the text from the internet, or from a local database (the internet part is working fine, I load the text from a php script, that is made by a friend of mine whose enterprise handles SMS messages reception, so Ive even tried my app by sending a message myself), and maybe an image between each message, like a logo, instead of an '*' or any other symbol. Now, If youre still with me, the problem is, that the application is running sort of slow, and I need it to be running really smooth, now Im gonna explain the inner guts of it: The app is composed of a JFrame, in which I just paint the background in blue (or any color for instance), and then in the TV editing room you can take a software and make the blue/whatever color transparent (like in the movies with the green background). Second, I have the scroll rectangle which is black and the messages runnin through the rectangle with a white font. Basically I use an infinite while loop, in which I check for new messages, use a crappy double buffer with Graphics2D and then paint the resulting image in the screen. This is the diagram
 ____________________________________________
|                                            |
|                                            |
|       blue/green background                |
|                                            |
|                                            |
|____________________________________________|
|          black "scroll" rectangle          |
| message * message * message                |
|____________________________________________|

The question is, how should I make this better, for example, what kind of graphics component should I use, a canvas maybe? And what would be the best way to make the double buffer having in account the '*' will be replaced with an image (perhaps, a PNG with an alpha channel) Have in account the issue is speed, and the fact Ill load the -dynamic- data from the internet or a localhost DB server, not a simple text file with static content... Thats it folks, I wanna thank you beforehands for taking your time to read this... Regards

##### Share on other sites
I would say your speed issue has to do with the "While Loop" checking for messages perhaps you would want to pause the thread that the while loop is running in for a few milliseconds.

Put the While loop into a run() method and then use the this.sleep( milliseconds) method to allow the thread to pause for a while. This might increase some graphics performance if not then try decreasing the number of refreshes for the screen. Swing initially refreshes the screen a number of times whenever you call repaint(). Try calling setIgnoreRepaint( boolean ) on the JFrame or any component and then add in calls to the paint( Graphics g) method whenever needed.

##### Share on other sites
Well thanks for the replies.

5MinuteGaming, my speed issue is that it is too slow! not to fast, hehe, so Id like to optimize it to run faster...
I do have it in a run method, i.e Its a thread, and the sleep is set to 0, and runs slow, so imagine if I would add some ms to it... it would be reaaaally slow.
Im gonna have in account the setIgnoreRepaint(), but anyways remember I have to paint the screen all the time, in order to scroll the text, probably the only part I need to keep static (no paints) is the background, and this is a fullscreen app, so noone will put a window in front of it, its supossed to run in a privileged mode

##### Share on other sites
Well I suggested putting in a sleep in the while loop because I was assuming that in your while loop you were only checking for incoming messages and doing the scrolling and repainting in another thread.

How fast is your text supposed to be scrolling do you have that timed or just letting it run as fast as possible?

Cause you would only need to update the window everytime the text scrolls! You might want to change the value scrolled as well. For instance make the text move further every 10 milliseconds.

##### Share on other sites
Well, its supossed to run -as you said- as fast as possible, maybe if it ran fast as hell that would be fine, and maybe I could add an FPS-like limit.
Have you ever seen the TV shows Im talking about, thats how smooth its supossed to run, so I cannot stop the text for more than 1 sec or it would look like "cut" if you know what I mean
Thanks for helping me out

##### Share on other sites
No problem I tried. And I think I know what type of scrolling display yours talking about. Good luck with it! And if you do figure out how to make it run faster please post how you did it I'd be interested to know.

You might also want to look into using graphics accleration with java couldn't hurt. I'm afraid I haven't had to do much graphics acceleration so I can't help you there.

##### Share on other sites
You need to sync the rendering with the refresh rate. In your case the refresh rate of the television system in your country (PAL / NTSC). Maybe you need a special graphics card that is designed for this kind of thing.

Use OpenGL to be sure you've get enough performance. I suggest you look into LWJGL (www.lwjgl.org). I think princec (http://www.gamedev.net/community/forums/profile.asp?mode=display&id=28307) used an early version of LWJGL to do some television graphics. He is one of the creators of that library and usually very helpful. Go the the lwjgl forum and ask your question there, and I'm sure you'll get a quick answer.

1. 1
2. 2
3. 3
Rutin
17
4. 4
5. 5

• 14
• 9
• 9
• 9
• 10
• ### Forum Statistics

• Total Topics
632912
• Total Posts
3009185
• ### Who's Online (See full list)

There are no registered users currently online

×