• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

adding applet to the page...

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Once I load this applet up on my html page, all other information in the page disappears, can some one help me find the mistake I am making
/* A simple banner applet
This applet creates a thread that scrolls the message contained in msg right to left
across the applets window.
*/
import java.awt.*;
import java.applet.*;
import java.awt.Font;
/*<applet code = "simplebanner" width="860" height="15">
</applet>
*/
public class simplebanner extends Applet implements Runnable{
String msg = " This text will scroll across the screen... ";



boolean stopFlag;
Thread t = null;
AppletContext ac;
int x,y;

Font textfont = new Font("Times New Roman",Font.ITALIC,15);

public void init(){
setBackground(Color.black);
setForeground(Color.yellow);
setFont(textfont);
msg = " " + msg;
msg += " ";
x=10;
y=12;

}

public void start(){
t= new Thread(this,"T");
stopFlag= false;
t.start();
ac = getAppletContext();
}



public void run(){
char ch;

for( ; {
try{
t.sleep(100);
repaint();
ch = msg.charAt(0);
msg = msg.substring(1,msg.length());
msg += ch;
if (stopFlag)
break;
} catch(InterruptedException e){}
}
}
public void stop(){
stopFlag=true;
t=null;
}

public void paint(Graphics g){
g.drawString(msg,x,y);
}
}

Thanks
Deepak
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic