Results 1 to 6 of 6
  1. #1
    rish is offline Member
    Join Date
    Jun 2014
    Posts
    6
    Rep Power
    0

    Default Java Applet error

    please help me with this basic applet program
    i'm beginner and need some clarification with working of this program!

    import java.awt.Graphics;
    import java.awt.Font;
    import java.awt.Color;
    {
    public class Helloapplet extends java.applet.Applet{
    Font f=new Font(“TimesRoman”,Font.BOLD,36);
    public void paint(Graphics g)
    {
    g.setFont(f);
    g.setColor(Color.red);
    g.drawString(“Hello again!”, 5, 50);
    }
    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default Re: Java Applet error

    What does this code do? What do you expect it to do?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,436
    Blog Entries
    7
    Rep Power
    20

    Default Re: Java Applet error

    @OP: I moved your post to its own thread (you hijacked an old zombie thread). b.t.w. why are you using Applets instead of JApplets? Did you read the API documentation for those classes?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    rish is offline Member
    Join Date
    Jun 2014
    Posts
    6
    Rep Power
    0

    Default Re: Java Applet error

    i want this applet to get displayed in my browser by writing this html script..
    <HTML>
    <HEAD>
    <TITLE>Another Applet</TITLE>
    </HEAD>
    <BODY>
    <P>My second Java applet says:
    <APPLET CODE=”HelloApplet.class” WIDTH=200 HEIGHT=50>
    </APPLET>
    </BODY>
    </HTML>

    ________
    but this applet program is showing compilation error!!

  5. #5
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Java Applet error

    Hi,

    why don't you give us the error details? That would help us to help you. It is very likely that we take the time to read your post. But it is very unlikely that we copy and past your code in the hope that you provided the correct code and that we get the exact same error.

    I just had a quick look:
    Helloapplet.java:4: error: class, interface, or enum expected
    {
    ^
    So in line 4 the { is wrong. instead "class", "interface" or "enum" is expected. It is quite self explaining, don't you think?

    When you fix that problem you might run into the next problem: You might have used the wrong quotes. In java you have to use the " and no quotes that go to the right or left as it is used when writing text in a word processing application.

    And at the end you might run into trouble because most things are case sensitive:
    Your class has the name "Helloapplet"
    So the .java file should be "Helloapplet.java"
    And the .class file is then "Helloapplet.class"
    So you should write it that way in your html file, too. (Maybe an operating system like Windows does not have problems that way but other applications are case sensitive and you should simply take care of that!)

    Konrad

  6. #6
    rish is offline Member
    Join Date
    Jun 2014
    Posts
    6
    Rep Power
    0

Similar Threads

  1. java applet error
    By The "G" in forum New To Java
    Replies: 3
    Last Post: 06-02-2014, 08:13 PM
  2. Java Applet Security Error
    By zachvac in forum Java Applets
    Replies: 1
    Last Post: 04-09-2014, 11:58 PM
  3. java applet error
    By jobud9 in forum New To Java
    Replies: 9
    Last Post: 01-21-2012, 07:36 PM
  4. Certification Error on Java Applet
    By netsuvi in forum Java Applets
    Replies: 0
    Last Post: 06-21-2011, 10:16 AM
  5. Java Applet Runtime error
    By sarwar1234 in forum Java Applets
    Replies: 12
    Last Post: 09-21-2010, 02:26 PM

Posting Permissions

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