Please visit our sponsor
UNKNOWN //************************************** //HTML for :Easy simple scrolling banner applet //************************************** <applet code="scroll.class" width="640" height="14"> <param name="message" value="Hello!"> </applet> //************************************** // Name: Easy simple scrolling banner applet // Description:A Very simple java scroller Applet. Simply change the internals to make it do what you want! // By: Jonathan Barker // // // Inputs:Put a param called message for your message... // // Returns:None // //Assumes:Compile with sun's javac 1.1 compiler. // //Side Effects:None //This code is copyrighted and has limited warranties. //Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.1957/lngWId.2/qx/vb/scripts/ShowCode.htm //for details. //************************************** // Cute little scrolling banner... import java.applet.Applet; import java.awt.*; public class scroll extends Applet implements Runnable { String message; Image messageimage; Graphics messagegraphics; Thread me; int xpos; int ypos; int textwidth; public void init() { setBackground(Color.black); // Background color of applet. Try Color.white or Color.red and so on... message = getParameter("message"); messageimage = createImage(size().width, size().height); messagegraphics = messageimage.getGraphics(); xpos = size().width + 10; ypos = 12; // position to look right textwidth = 7 * message.length(); me = new Thread(this); me.start(); } public void run() { while(true) { xpos--; if (xpos &lt; -textwidth) { xpos = size().width + 10; } try { Thread.sleep(10); } catch (InterruptedException _ex) { } repaint(); } } public void paint(Graphics g) { messagegraphics.setColor(Color.black); // Background colour again messagegraphics.fillRect(0,0,size().width + 1, size().height + 1); messagegraphics.setColor(Color.white); // Text colour here try { messagegraphics.setFont(new Font("Arial",0,10)); // change font or font size (Fontname, 0, Size) } catch(NullPointerException _ex) { } messagegraphics.drawString(message, xpos, ypos); g.drawImage(messageimage, 0, 0, this); } public void update(Graphics g) { paint(g); } }