DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2002
    Posts
    23

    Angry text not appearing in applet

    the following program compiles and runs but the text does not appear in the applet after appletviewer command,

    import java.awt.Container;
    import java.swing.*;

    public class SquareInt extends JApplet {
    public void init() {
    String output = " ";

    JTextArea outputArea = new JTextArea (10, 20);

    Container c = getContentPane();

    c.add(outputArea);

    int result;

    for (int x = 0; x <= 10; x++) {
    result = square(x);
    output += "The square of " + x + "is " + result + "\n";

    }
    outputArea .setText(output);
    }

    public int square(int y) {
    return y * y;

    }
    }



    // Square.html


    <HTML>
    <HEAD>
    <TITLE> This is a simple program </TITLE>
    </HEAD>
    <BODY>
    Here is the output of my program:
    <APPLET CODE = "SquareInt.class" WIDTH = 60 HEIGHT = 40 >
    </APPLET>
    </BODY>
    </HTML>

    "C How To Program" 3rd edit., Deitel & Deitel, page 896 & 897

  2. #2
    Join Date
    Oct 2002
    Posts
    23

    Unhappy found error

    found error in the code. on my pc i had Init() and not init(). init () is a method and not a class so init() is the correct name. seemed to have written it correctly in my post although i had it wrong on my pc. sorry for the mislead and thanks to all who tried to fix the code.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links