 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Lothar Sturm Guest
|
Posted: Sat Jul 30, 2005 4:30 pm Post subject: Newbie thread.sleep probs with Mac OSX |
|
|
Hello,
could anyone help Java-Dummy with Mac OSX (3.9 and 4.2)?
I found this little applet below, but it doesn't work with OSX. It is
well doing the pause on Win XP and Mac OS9.
Could you give me a tip or link, how to create java-code which works on
nearly all systems?
Thank you!
Lothar
here is the applet:
import java.applet.*;
import java.awt.*;
public class Scheibea extends Applet{
public Scheibea(){
setBackground(Color.green);
}
public void zeitschleife(){
try {Thread.sleep(500);}
catch(InterruptedException e) {return;}
}
public void paint(Graphics stift){
for (int x=50;x<500;x=x+10){
stift.setColor(Color.red);
stift.drawOval(x,100,30,30);
zeitschleife();
stift.setColor(Color.blue);
stift.drawOval(x,100,30,30);
}
}
}
--
Fuer Replies XX bitte loeschen.
No html-Mails please!
|
|
| Back to top |
|
 |
John B. Matthews Guest
|
Posted: Sun Jul 31, 2005 2:22 am Post subject: Re: Newbie thread.sleep probs with Mac OSX |
|
|
In article <1h0iz5x.1ovbfxnvpko12N%lotstuXX (AT) arcor (DOT) de>,
[email]lotstuXX (AT) arcor (DOT) de[/email] (Lothar Sturm) wrote:
| Quote: | Hello,
could anyone help Java-Dummy with Mac OSX (3.9 and 4.2)?
I found this little applet below, but it doesn't work with OSX. It is
well doing the pause on Win XP and Mac OS9.
Could you give me a tip or link, how to create java-code which works on
nearly all systems?
Thank you!
Lothar
here is the applet:
import java.applet.*;
import java.awt.*;
public class Scheibea extends Applet{
public Scheibea(){
setBackground(Color.green);
}
public void zeitschleife(){
try {Thread.sleep(500);}
catch(InterruptedException e) {return;}
}
public void paint(Graphics stift){
for (int x=50;x<500;x=x+10){
stift.setColor(Color.red);
stift.drawOval(x,100,30,30);
zeitschleife();
stift.setColor(Color.blue);
stift.drawOval(x,100,30,30);
}
}
}
|
It looks like the Thread that's sleeping is not the same one that's
painting. To see another approach, have a look at the Sun example below;
it's included when you install Xcode:
/Developer/Examples/Java/Applets/NervousText/NervousText.java
--
John
jmatthews at wright dot edu
www dot wright dot edu/~john.matthews/
|
|
| Back to top |
|
 |
John B. Matthews Guest
|
Posted: Sun Jul 31, 2005 2:22 am Post subject: Re: Newbie thread.sleep probs with Mac OSX |
|
|
In article <1h0iz5x.1ovbfxnvpko12N%lotstuXX (AT) arcor (DOT) de>,
[email]lotstuXX (AT) arcor (DOT) de[/email] (Lothar Sturm) wrote:
| Quote: | Hello,
could anyone help Java-Dummy with Mac OSX (3.9 and 4.2)?
I found this little applet below, but it doesn't work with OSX. It is
well doing the pause on Win XP and Mac OS9.
Could you give me a tip or link, how to create java-code which works on
nearly all systems?
Thank you!
Lothar
here is the applet:
import java.applet.*;
import java.awt.*;
public class Scheibea extends Applet{
public Scheibea(){
setBackground(Color.green);
}
public void zeitschleife(){
try {Thread.sleep(500);}
catch(InterruptedException e) {return;}
}
public void paint(Graphics stift){
for (int x=50;x<500;x=x+10){
stift.setColor(Color.red);
stift.drawOval(x,100,30,30);
zeitschleife();
stift.setColor(Color.blue);
stift.drawOval(x,100,30,30);
}
}
}
|
It looks like the Thread that's sleeping is not the same one that's
painting. To see another approach, have a look at the Sun example below;
it's included when you install Xcode:
/Developer/Examples/Java/Applets/NervousText/NervousText.java
--
John
jmatthews at wright dot edu
www dot wright dot edu/~john.matthews/
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|