Forums Register Login

Subsequent .drawString statements not visible

+Pie Number of slices to send: Send
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);

}
}
+Pie Number of slices to send: Send
Appears to have been a classpath problem.
They worship nothing. They say it's because nothing is worth fighting for. Like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 759 times.
Similar Threads
FontMetrics
JAVA architecture
Sending dynamic content by email in jsp
How to catch number errors?
\n with drawString()
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:37:27.