Article View: cn.bbs.comp.lang.java
Article #23824Re: My Program Won't Run Properly - Please Help !
From: evpu
Date: Sun, 06 Aug 2000 00:00
Date: Sun, 06 Aug 2000 00:00
86 lines
2401 bytes
2401 bytes
if u wanna function run() will be run in your program,so u must declare your
applet like this:
public class Integers extends java.applet.Applet implements Runnable{
...
}
Reginald Manteaw <reg@raphouse.freeserve.co.uk> wrote in message
news:86rbjf$glp$1@news8.svr.pol.co.uk...
> Hi All,
>
> I am a new beginner in Java who gave myself an exercise which briefly
> requires that I produce an applet which generates positive integers
> (1,2,3,..) and displays each one, together with a suitable message, i.e.
> "The number is : 2", at two-second intervals. Can anyone point out why my
> program below doesn't produce the expected results when run please ?
>
>
> /*an applet which generates positive integers (1,2,3...)and displays each
> one, together
> with a suitable message, at two-second intervals*/
>
> import java.awt.*;
>
> import java.awt.Font;
>
> import java.awt.Color;
>
> import java.awt.Graphics;
>
>
> public class Integers extends java.applet.Applet
> {
>
>
> Font f = new Font ("Courier",Font.BOLD,24);
>
> int num, value; // declare variables
>
>
> public void init()
> {
>
> Font f = new Font("Courier",Font.BOLD,24);
> }
>
> public void run()
> {
>
> while (true)
> {
> for (num = 1; num >= 1; num = num++)
>
> {
> value = num;
> repaint();
> try {Thread.sleep(1000);}
> catch (InterruptedException e){}
>
> }
> }
> }
>
> public void update(Graphics g)
> {
> paint(g);
> }
>
> public void paint (Graphics g)
> {
> g.setFont (f);
> g.setColor(Color.red);
> g.drawString("The number is : " + value, 10, 20);
> }
>
>
> }
>
>
>
> Thanks
>
>
>
>
>
>
Technical Details
Message-ID:
<8mhfq3$1ueo$1@news.cz.js.cn>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<86rbjf$glp$1@news8.svr.pol.co.uk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f6cb0,6c3b22ffe06af1d5,start X-Google-Attributes: gidf6cb0,public From: "evpu" <evpu@263.net> Subject: Re: My Program Won't Run Properly - Please Help ! Date: 2000/08/06 Message-ID: <8mhfq3$1ueo$1@news.cz.js.cn> X-Deja-AN: 654884862 References: <86rbjf$glp$1@news8.svr.pol.co.uk> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 X-Complaints-To: usenet@news.cz.js.cn X-Trace: news.cz.js.cn 965493379 63960 202.104.98.71 (5 Aug 2000 16:36:19 GMT) Organization: The news server of Changzhou TeleCom X-MSMail-Priority: Normal NNTP-Posting-Date: 5 Aug 2000 16:36:19 GMT Newsgroups: cn.bbs.comp.lang.java