• Post Reply Bookmark Topic Watch Topic
  • New Topic

Subsequent .drawString statements not visible  RSS feed

 
Greenhorn
Posts: 8
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am practicing with a textbook (Java for COBOL) example which is not performing as expected.
The applet viewer displays the first .drawString statement but not the others.
So my question is have i mistyped something or do I have an installation/system/environment
problem?

(Sorry I wasn't sure how to annotate the code)

import java.applet.Applet;
import java.awt.Graphics;

public class HelloWorld extends Applet
{
public void paint(Graphics g)
{
String tempMsg;

g.drawString("Hello applet World!", 5, 25);

// Create a new instance of the ErrorMsg class.
ErrorMsg myErrorMsg = new ErrorMsg ();

// Print the contents of the public data member msgText in our class.
tempMsg = myErrorMsg.getErrorMsg ();
g.drawString (tempMsg, 5, 35);

// Set msgText to some text String, and print its contents.
myErrorMsg.setErrorMsg ("Some Text");
tempMsg = myErrorMsg.getErrorMsg ();
g.drawString (tempMsg, 5, 45);

// Call the setErrorMsg method to set the text to some other text, and
// print its contents.
myErrorMsg.setErrorMsg ("Some New Text");
tempMsg = myErrorMsg.getErrorMsg ();
g.drawString (tempMsg, 5, 55);

// Create a new instance of the ErrorMsg class.
ErrorMsg myErrorMsg2 = new ErrorMsg ();

// Set the text item to some text String, and print its contents.
myErrorMsg2.setErrorMsg ("Some Text for #2");
tempMsg = myErrorMsg2.getErrorMsg ();
g.drawString (tempMsg, 5, 75);

// Print the text item in the original object.
tempMsg = myErrorMsg.getErrorMsg ();
g.drawString (tempMsg, 5, 85);

}
}
 
S Garcia
Greenhorn
Posts: 8
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Appears to have been a classpath problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!