🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.lang.java
Article #23927

My Program Won't Run Properly - Please Help !

#23927
From: Reginald Manteaw
Date: Fri, 28 Jan 2000 00:00
72 lines
1955 bytes
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: <86rbjf$glp$1@news8.svr.pol.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f6cb0,9eaa0466fb4bce6d,start
X-Google-Attributes: gidf6cb0,public
From: "Reginald Manteaw" <reg@raphouse.freeserve.co.uk>
Subject: My Program Won't Run Properly - Please Help !
Date: 2000/01/28
Message-ID: <86rbjf$glp$1@news8.svr.pol.co.uk>
X-Deja-AN: 578635908
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
X-Complaints-To: abuse@theplanet.net
X-Trace: news8.svr.pol.co.uk 949039535 17081 62.136.194.9 (28 Jan 2000 06:05:35 GMT)
Organization: Customer of Planet Online
X-MSMail-Priority: Normal
NNTP-Posting-Date: 28 Jan 2000 06:05:35 GMT
Newsgroups: cn.bbs.comp.lang.java