⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textcycler.java

📁 在WEB页面循环显示一组信息。
💻 JAVA
字号:
/* TextCycler.java   * * Raven * raven@ravenmatrix.com * http://www.ravenmatrix.com  * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details at http://www.gnu.org  */import java.applet.*;import java.awt.*;import java.util.StringTokenizer;public class TextCycler extends Applet implements Runnable {Thread runner = null;    Graphics cycle;Image Item;Font font;int delay = 100;String messages;String CurrentMessage = "";Dimension size;FontMetrics a;public void init() {font = new Font("Courier", Font.PLAIN, 18);messages= getParameter("messages");size = size(); Item = createImage(size.width, size.height);cycle =  Item.getGraphics();a = cycle.getFontMetrics();String param = getParameter("delay");if (param != null) delay = Integer.valueOf(param).intValue();}public void start(){if (runner == null){runner = new Thread(this);runner.start();}}public void stop(){if (runner != null){runner.stop();runner = null;}}public void paint(Graphics g){FontMetrics a = cycle.getFontMetrics();cycle.setColor(Color.white);cycle.fillRect(0,0,size.width,size.height);cycle.setColor(Color.black);cycle.setFont(font);cycle.drawString(CurrentMessage, (size.width - a.stringWidth(CurrentMessage))/2,size.height - a.getMaxDescent());if (Item != null)g.drawImage(Item, 0, 0, this);}public void run(){StringTokenizer t = new StringTokenizer(messages, "|");CurrentMessage = t.nextToken();    while (true){try{                                   if(t.hasMoreTokens()){CurrentMessage = t.nextToken();    }else{t = new StringTokenizer(messages, "|");CurrentMessage = t.nextToken();    }repaint();Thread.sleep(delay);}catch(InterruptedException e){stop();}}}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -