Scrolling status bar message

Scrolling status bar message

How can I make a message that will scroll in the status bar?

The following applet constructs a thread, passing it a messageand its browser context. The thread perpetually sleeps for 100 miliseconds and computes three strings:

 prefix = last i chars of message;   infix  = first j chars of filler;  // filler = ”     ”   suffix = first k chars of message;
prefix = last j chars of filler;   infix  = first k chars of message;     suffix = first i chars of filler;
where i + j + k = blen = fixed banner length, then calls:
 context.showStatus(prefix + infix + suffix);
Each time through the loop, i, j and k are adjusted to createthe illusion of scrolling. (I might add that I’m not terriblyproud of the awkward way I compute i, j and k.)

From the applet, users can suspend or resume the thread, orchange the message.

The code can be modified to create a scrolling text field bypassing the text field rather than a context to the thread.In this case we use the statement:

msgField.setText(prefix + infix + suffix);
Finally, the 100 milisecond figure was arrived at experimentally.Shorter times make the text scroll too fast and make the threaddifficult to interrupt.
*/import java.awt.*;import java.applet.*;class Scroller extends Thread {   AppletContext context;   String msg;   String filler = ”          “;   public Scroller(String m, AppletContext ctxt) {      context = ctxt;      msg = m;   }   public void run() {      int mlen = msg.length(),          flen = filler.length(),          blen = mlen + flen – 2,          i = 0,          j = 0,          k = 0,          h = 0;      String prefix, infix, suffix;      while (true) {         if (i < mlen) {            prefix = msg.substring(i, mlen);            h = mlen - i;            infix = filler.substring(0, j = Math.min(blen - h, flen));            if (blen - (h + j) >= 0)               suffix = msg.substring(0, Math.min(blen – (h + j), mlen));            else               suffix = “”;         }         else {            prefix = filler.substring(j = (i – mlen), flen);            h = flen – j;            infix = msg.substring(0, k = Math.min(blen – h, mlen));            if (blen – (h + k) >= 0)               suffix = filler.substring(0, Math.min(blen – (h + k), flen));            else               suffix = “”;         }         i = (i + 1) % (flen + mlen);                  try {            sleep(100);         }         catch (InterruptedException e) {            e.printStackTrace();         }         context.showStatus(prefix + infix + suffix);      } // while   } // run}         public class BannerDemo extends Applet {   private AppletContext context;   private String message;   private Scroller scrollGuy;   private boolean scrolling = true, msgChanged = false;   private TextField msgField;   public void init() {      add(new Button(“Suspend/Resume”));      context = getAppletContext();      message = getParameter(“msg”);      msgField = new TextField(message, 20);      add(msgField);      scrollGuy = new Scroller(message, context);   }   public void start() {      scrollGuy.start();      scrolling = true;   }   public void stop() {      scrollGuy.stop();      scrolling = false;   }   public boolean handleEvent(Event e) {      if ( == Event.WINDOW_DESTROY) System.exit(1);      return super.handleEvent(e);   }   public boolean action(Event e, Object arg) {      if (arg.equals(“Suspend/Resume”) ) {         if (scrolling) {            scrollGuy.suspend();            scrolling = false;         }         else if (msgChanged) {            scrolling = true;            msgChanged = false;            scrollGuy.stop();            scrollGuy = new Scroller(msgField.getText(), context);            scrollGuy.start();         }         else {            scrollGuy.resume();            scrolling = true;         }      }      else if ( == msgField)         msgChanged = true;      else return false;      return true;   }   }

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of