Java Reference
In-Depth Information
myErrorMsg2.setErrorMsg ("Some Text for #2");
tempMsg = myErrorMsg2.getErrorMsg ();
System.out.println (tempMsg);
tempMsg = myErrorMsg2.getTranslation ();
System.out.println (tempMsg);
10. Save, compile, and rerun the HelloWorld application, and then observe
the output. Notice how LANGUAGECODE applies to all instances of
TextMessage :
Hello World!
Some Text
Some Text
Some Text -> French Text
Some Text for #2
Some Text for #2 -> French Text
11. Let's create and use the PrintfileErrorMsg class. Create a new java source
file in the C:\java4cobol directory named PrintfileErrorMsg.java. Insert
these lines of text into the class file definition:
//
//
// PrintfileErrorMsg
//
//
class PrintfileErrorMsg extends ErrorMsg {
private static int outputLineSize = 80;
public int linesToSkip = 0;
private int charsToSkip = 0;
// Define a setErrorMsg method that establishes the number of characters
// to output in order to center the text from ErrorMsg.
public void setErrorMsg (String inputMsg) {
super.setErrorMsg (inputMsg);
charsToSkip = (outputLineSize - msgSize) / 2;
// Print out this error message.
printLine ();
}
// Define a new method that prints this error message to the standard
// output. It will be centered in the output line (based on the size of
// outputLineSize). linesToSkip lines will be skipped first.
Search WWH ::




Custom Search