This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Need help with applet

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 applets that I need to merge into one. It is for a class, and my instructor says there is a very small amount that needs to be changed in the code.
The first one displays a simple banner. Besides merging it with the other applet, the String msg needs to be changed to a Label. I am having trouble with this because after changing it to a Label, the statements such as charAt and substring won't work. Here is the code:

The other applet is a calculator. The banner scrolls on top, and the calculator can be used while the banner is scrolling. I would appreciate any help you can give me with this.
Thanks in advance. Here is the calculator code.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my instructor says there is a very small amount that needs to be changed in the code
Your instructor is correct.
the String msg needs to be changed to a Label. I am having trouble with this because after changing it to a Label, the statements such as charAt and substring won't work.
That's because a Label is not a String and as such a Label doesn't have the methods of a String available for use.
Browse Sun's documentation for the Label class. You'll discover a method you might find useful which returns a String object that you can use just as you were using your original String (hint: the method is Label::getText()).
For beginning to figure out what's involved with merging two applets into one applet, I'd suggest doing a quick practice session on two very simple applets. Try these two:


Good Luck.
 
Randy Helene
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help.
I did look at the link you gave me. I also figured out that I needed to get rid of the paint and repaint methods and add setText instead.
It works correctly now.
 
    Bookmark Topic Watch Topic
  • New Topic