Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

adding applet to the page...

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic