aspose file tools*
The moose likes Applets and the fly likes multithreading issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "multithreading issue" Watch "multithreading issue" New topic
Author

multithreading issue

R. Aw
Greenhorn

Joined: Feb 02, 2008
Posts: 4
I cant get my banner text to show up in my applet only the calculator shows up..so do i need to add a label and display the rotating text in the labels, instead of using the drawString(). if so, how do i do this?

here is my code:

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.applet.*;

/*
*
<applet code="SimpleBanner" width=350 height=100>
</applet>
*/

public class SimpleBanner extends Applet implements Runnable {
String msg = " Say YES to Multi-threading ";
Thread t = null;
Thread threadCal = null;
int state;
boolean stopFlag;
Calc c = new Calc();
Panel p1 = new Panel();
Panel p2 = new Panel();

/*In the SimpleBanner class, add a label and display
the rotating text in the labels, instead of using the drawString().*/






// Set colors and initialize thread.
public void init() {

setLayout(new GridLayout(2, 1));
setBackground(Color.yellow);
setForeground(Color.black);
add(p1);

c.init();
p2.setBackground(Color.pink);
p2.setLayout(new GridLayout(1,1));
add(p2);
p2.add(c);




}

// Start thread
public void start() {
t = new Thread(this);
threadCal = new Thread();
stopFlag = false;
t.start();
threadCal.start();
}

// Entry point for the thread that runs the banner.
public void run() {
char ch;

// Display banner
for( ; ; ) {
try {
repaint();
Thread.sleep(250);
ch = msg.charAt(0);
msg = msg.substring(1, msg.length());
msg += ch;
if(stopFlag)
break;
} catch(InterruptedException e) {}
}
}

// Pause the banner.
public void stop() {
stopFlag = true;
t = null;
}

// Display the banner.
public void paint(Graphics g) {
g.drawString(msg, 20, 30);
}
} //public class SimpleBanner extends Applet implements Runnable {
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: multithreading issue