File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes adding applet to the page... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "adding applet to the page..." Watch "adding applet to the page..." New topic
Author

adding applet to the page...

Elijah Israel
Greenhorn

Joined: Mar 31, 2001
Posts: 3
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

Elijah
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: adding applet to the page...
 
Similar Threads
multithreading issue
Doubt In the applet event code
Need help with applet
MultiThreading issue....
Java ScrollBanner