• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Subsequent .drawString statements not visible

 
Greenhorn
Posts: 8
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Appears to have been a classpath problem.
 
reply
    Bookmark Topic Watch Topic
  • New Topic