Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Background image and scroll text???

 
Daniel Lugn
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Daniel Lugn
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried that but the applet doesn't seem to get any of the parameters. It is just grey...
Regards
/Daniel
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using IE 5.0...
/D
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
 
Daniel Lugn
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic