Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-10-2008, 03:53 PM
Moderator
 
Join Date: Nov 2007
Posts: 1,617
Java Tip will become famous soon enoughJava Tip will become famous soon enough
Applet with scrolling status line
Sometimes it is a good idea to have a scrolling status line in applets. The example below will help you in this.

Code:
public class ScrollStatus extends Applet implements Runnable { Thread thread; String message; StringBuffer buffer; int at; int width; public void init(){ message = getParameter("message"); if(message == null) message = " Isn't scrolling text in the status line annoying? "; String ws = getParameter("width"); if(ws == null) { width = 36; } else{ width = Integer.valueOf(ws).intValue(); } if(width < 5 || width > 180) { width = 36; } buffer = new StringBuffer(width); buffer.setLength(width); at = 0; if(message.length() < width) { char buf[] = new char[width]; for(int i = 0; i < width; ++i) { buf[i] = ' '; } message.getChars (0, message.length(), buf, (width - message.length()) / 2); message = new String(buf); } } public void start(){ thread = new Thread(this); thread.start(); } public void stop(){ thread.stop(); } public void scroll(){ int ml = message.length(); int k = at; for(int i = 0; i < width; ++i, ++k){ if(k >= ml) { k = 0; } buffer.setCharAt(i, message.charAt(k)); } getAppletContext().showStatus(buffer.toString()); at++; if(at >= ml) { at = 0; } } public void run(){ while(true){ scroll(); try{ Thread.sleep(25); // wait 25 ms } catch(InterruptedException e){ break; } } } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
AWT Table Scrolling albert_kam AWT / Swing 0 01-03-2008 12:37 PM
HTTP Status 404 - Servlet action is not available onceuponatime Java Servlet 1 12-11-2007 05:29 PM
Reading in data from file line by line bluekswing New To Java 1 10-02-2007 01:19 AM
Status Code 404 tommy Java Servlet 1 08-06-2007 09:52 PM
Hide hyperlink address on status bar simon JavaServer Pages (JSP) and JSTL 2 07-24-2007 11:34 AM


All times are GMT +3. The time now is 12:27 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org