yes that could be it
Type: Posts; User: Norm
yes that could be it
There is/are method(s) that will give you the width of a character when it is drawn using a font.
I don't remember what class it is in. You'll have to do some research.
Get each character, get its...
Where are you drawing these letters? Look at arguments 4 and 5
g.drawChars(chars, i, i+1,300,300);
Have you read the API doc for this method? What are the second and third args?
What statement is causing the error?
As you suggested in your last post, check the scope of the variable. Define the variable at the class level and make sure there isn't another variable with the same name at an inner scope.
Good idea to check the scope of your variables. Make sure you don't have definitions of variables with the same names at different levels of scope.
Use println statement before the if statement...
Use variables in the new Color constructor that do not have 0 values.
new Color(rd, grn, bl); // be sure rd, grn and bl are not all 0
No idea what you are talking about.
Constructor?...
Add a println after that statement to verify what is in the chars array:
System.out.println("chars=" + java.util.Arrays.toString(chars));
Then you'll know
Can you show me the code that puts values in the array?
Then it is not being initialized.
Add printlns after the statement that initializes it
and before the statement that uses it.
See what order they print out in.
Its a question of where/when the code in your program is being executed. If the code that uses a variable before it is initialized is executed BEFORE the code that initializes the variable, then you...
Yes, that is exactly how you can get a NullPointerException.
You must initialize a variable BEFORE you use it.
I'm sure you have heard this before. Seeing that you have 1219 posts.
Please post it.