The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

I am new to Java programming by SkyHi 2005-01-27 05:46:56
and I'm sitting in my class, teacher can't figure this out, nor can I, it's only my second day. Please tell me what's wrong with this code :

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

public class distance extends Applet implements ActionListener
{
double MI, KM;
Label prompt;
TextField input;

public void init( )
{
prompt = new Label ("Enter the number of miles you've run: ") ;
add (input) ;

input.addActionListener (this) ;
}
public void actionPerformed (ActionEvent e)
{
MI = Integer.parseInt (input.getText ( ) ) ;
KM = MI / .62;
repaint ( ) ;
}

public void paint (Graphics g)
{
g.drawString ("You have run " + KM + " kilometers." , 70, 75);
}
}

I get an error when I try to run it : " Exception in thread "main" java.lang.NoSuchMethodError: main"

Please help

Steve
[ Reply ]
  I think you're trying to run it the wrong way. by dodrian2005-01-27 06:02:25
    I'll try it out, but we're just trying to use by SkyHi2005-01-27 06:03:52
      It ought to... by Hessofanes2005-01-27 06:50:56
  you haven't initialised 'input' by Jeff_UK2005-01-27 06:26:04
    and again : i may be wrong... by Jeff_UK2005-01-27 06:28:35
      DOH! It refers to the fact that you need a main() by Jeff_UK2005-01-27 07:39:38
        2nd thoughts, I have revision to do-back in 2hrs! by Jeff_UK2005-01-27 07:43:25
  I think Jeff UK is right on both accounts. by FenderSRV22005-01-27 07:19:59
    Disagree about the second. ;) by Hessofanes2005-01-27 11:54:19
  I've never used that particular by Master_Rahl222005-01-27 12:32:58

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)