• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Background image and scroll text???

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using IE 5.0...
/D
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
reply
    Bookmark Topic Watch Topic
  • New Topic