[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

An example of a marquee in an applet?

Posted on 2001-06-29
8
Medium Priority
?
1,591 Views
Last Modified: 2013-11-23
Hello,

I would like to display a scrolling "Welcome" marquee in an applet - how do you make one of these marquees using multithreading?  Can anyone give me an example please.

I'd really appreciate all the help.
0
Comment
Question by:bita
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 12

Accepted Solution

by:
ahosang earned 200 total points
ID: 6239270
Just a basic example:
import java.awt.*;
import java.applet.Applet;

public class Welcome extends java.applet.Applet implements Runnable {
   
   Font f = new Font("Arial Black", Font.BOLD, 24);
   Color col = new Color(204,153,0);
   Color back = new Color(249,249,249);
   String wel = new String("WELCOME TO MY SITE");
   Thread runner;
   int x;
   int stringSize;
   
   public void init() {
      setForeground(col);
      setBackground(back);
       setFont(f);
       FontMetrics fm=getFontMetrics(f);
       stringSize=fm.stringWidth(wel);
   }

   public void start() {
      if (runner == null) {
         runner = new Thread(this);
         runner.start();
      }
   }

   public void stop() {
      if (runner != null) {
         runner = null;
      }
   }

   public void run() {
      Thread thisThread = Thread.currentThread();
      x = 10-stringSize;
      int cont = size().width;
      while (runner == thisThread) {
         x = x + 2;
         repaint();
         try {
            Thread.sleep(20);
         } catch (InterruptedException e) { }
         if (x > cont) x = -stringSize;
      }
   }

   public void paint(Graphics screen) {
     
      screen.drawString(wel, x, 25);
   }
}
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 6239298
There are also hundreds of examples of these (some really flash/complex) at http://javaboutique.internet.com/text/horiz.html. Many of these will have full source code with them.
0
 

Author Comment

by:bita
ID: 6240191
hi ahosang,

Thank you for your example.  I tried to compile this code on the JDK1.2 but there was an error:

"Note:Welcome.java uses or overrides a deprecated API.  Recompile with "-deprecation" for details.
1 warning"

Can you tell me what this means and how to resolve this error please. Thanks again.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 15

Expert Comment

by:ozymandias
ID: 6240384
That is not an error.
It is a warning.
A deprecated method is a method that had been flagged for future removal from the API.

In this instance it is the method size() used in this line :

    int cont = size().width;

This method has been flagged as deprecated because it has been replaced by the method getSize(). You can use either but the compiler is warning you that it is better to use the newer method because eventually the old one will be removed and your code won't work. The size() method in this case has been deprecated since JDK 1.1, so that's quite a long time.

To correct the code change the line so it reads :
   
    int cont = getSize().width;

and all will be well.

0
 

Author Comment

by:bita
ID: 6240429
Hello ozymandias ,

Thank you for your quick reply to the message about the warning.  I recompiled the program and yes, all is now well.
-----------------------
Thanks to both ahosang and yourself , I now have a clear idea about scrolling text in an applet!

bita
0
 

Author Comment

by:bita
ID: 6240430
Hello ozymandias ,

Thank you for your reply to the message about the warning.  I recompiled the program and yes, all is now well.
-----------------------
Thanks to both ahosang and yourself , I now have a clear idea about scrolling text in an applet!

bita
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 6240658
Glad I could help :0)
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 8950454


No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


--  points to ahosang


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question