Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Location
    Atlanta, BAYBAY!
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Beginner help with using APPLET


    First post! I'm pretty excited to be getting into a forum that doesn't RickRoll me every 5 seconds.

    I'm taking intro to JAVA, and we are discussing the use of APPLET. He posted this code on our class website, and its not pulling up in my compiler. Is there something wrong with the code itself?

    I apologize if this is a n00bie b00bie post, but you gotta start somewhere right?
    Code:
    import java.applet.*;
    import javax.swing.JOptionPane;
    import java.awt.*;
    
    public class AppletTest extends Applet
    {
      public void init(){
           System.out.println("Applet initialization.");
      }
      
      public void start(){
         System.out.println("Applet starting.");
      }
    
    /**
     * public void stop(){
         System.out.println("Applet stopping.");
      }
    **/
    
    
    
        public void paint(Graphics g) {
          g.drawString("Hello ", 5, 15);
          String name = JOptionPane.showInputDialog("What is your name?");
          g.drawString("Hello " + name + ".     Welcome to GGC!", 5, 15);
        }
    }

    I understand that essentially is supposed to log what you type in as your name and display simple text output including your name in the text.

    But why the use of an applet? I can't investigate this myself b/c my compiler states:

    "Static Error: No method in AppletTest with name 'main' accepts arguments (String[])"

    when ever i attempt to run the code. Any sort of feedback on this would be so helpful. Thank you.

  • #2
    Regular Coder brad211987's Avatar
    Join Date
    Sep 2005
    Location
    Ohio
    Posts
    631
    Thanks
    10
    Thanked 50 Times in 50 Posts
    Been quite a while since I've even looked at an applet, but my guess is you are trying to simply execute the applet program using the java command, or the function of an editor. Applets cannot be run this way as far as I know. You will need to look into either embedding it into a mockup web page or using the applet viewer.

    A google search for the applet viewer turned up: http://www.kevinboone.com/howto_appletviewer.html

    That should get you going in the right direction.

  • #3
    Regular Coder
    Join Date
    Jan 2009
    Location
    india
    Posts
    145
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Applets don't need main(String args[]) method at all, they can't run as stand alone java program.
    You must embed it into an HTML page or use Applet viewer to execute it.

    Look at http://java.sun.com/j2se/1.3/docs/to...letviewer.html

    --------------
    SN Java Servlets


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •