text not appearing in applet


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: text not appearing in applet

  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.

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center