• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help with applet

 
Randy Helene
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.
 
Dirk Schreckmann
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic