This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Background image and scroll text??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Background image and scroll text??? " Watch "Background image and scroll text??? " New topic
Author

Background image and scroll text???

Daniel Lugn
Greenhorn

Joined: Aug 06, 2001
Posts: 6
Hi!
Can somebody help me with this!!
I want to make a Applet with a background image and a textstring scrolling from right to left on top of that.
I'm quite new to Java so I don't have a clue....
Thanx!!
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Here's some code that does what you want... just pass in the image name, text, text color, and speed of scrolling as parameters in the HTML...

[This message has been edited by Nathan Pruett (edited August 06, 2001).]


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Daniel Lugn
Greenhorn

Joined: Aug 06, 2001
Posts: 6
Hi!
Thanks for your answer.
I tried it and it compiled fine but nothing gets displayed when I run the applet in the browser.
Could it be something I�ve missed?
Regards
/Daniel
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Did you make sure the param tags in the HTML were correct? You need to specify the filename of your image, the text you want, the speed you want it to move, and the color you want the text to be... I was sloppy and didn't add any parameter checking code, so you have to specify all the params, else if any params are missing a NullPointerException will probably be thrown... Just to test stuff out, change the color param to 000000, so that it will show up as black. You will be able to see the text if the applet is running even if your image is not being loaded...

HTH,
-Nate
[This message has been edited by Nathan Pruett (edited August 07, 2001).]
Daniel Lugn
Greenhorn

Joined: Aug 06, 2001
Posts: 6
I tried that but the applet doesn't seem to get any of the parameters. It is just grey...
Regards
/Daniel
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Could you post what browser you are using and what version it is? Are there any error messages in the Java Console? This is very confusing.... It worked fine in appletviewer and IE 4.0 for me...

-Nate
Daniel Lugn
Greenhorn

Joined: Aug 06, 2001
Posts: 6
I'm using IE 5.0...
/D
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Daniel,
Where did you put your image file. If you have it with your html then you need to use getDocumentBase() instead of getCodeBase(). If it is in neither of those 2 places then you need to use
getImage(new URL("http;//whatever"),filename);


"JavaRanch, where the deer and the Certified play" - David O'Meara
Daniel Lugn
Greenhorn

Joined: Aug 06, 2001
Posts: 6
Hi,
The image is in the same folder as the class and the HTML-file that calls the class. I tried your tips but I couldn't get it to work...
Maybe you could take look at my code, to see if I've done some stupid beginner error!! Thanks for your time...
/Daniel
Here's my HTML-file:
-----------------------------------------------------------------
< html>
< head>< /head>
< body>
< applet code="BackgroundImageScroller.class" width="500" height="200">
< param name="image" value="BGimage.gif">
< param name="text" value="JavaRanch Rules!!!">
< param name="speed" value="5">
< param name="color" value="000000">
< /applet>
< /body>
< /html>
-----------------------------------------------------------------
And here's the Java-code:
-----------------------------------------------------------------

-----------------------------------------------------------------

[This message has been edited by Daniel Lugn (edited August 09, 2001).]
(edited by Cindy to format code)

[This message has been edited by Cindy Glass (edited August 09, 2001).]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Background image and scroll text???