Results 1 to 3 of 3
Umm...okay. I have just come across something very weird within Java, and I'm interested to see if anyone knows a way to fix this. I have the following bit of ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-17-2005 #1
Java String Lengths [SOLVED]
I have the following bit of code in a GUI application that I'm writing:
if(currentCode.length() > 11) tab_string = "\t"; else tab_string = "\t\t";
In both of those, there is an example where the arrow isn't lined up. However, there are also other examples (where the code is actually LONGER than the one not displaying properly) that have the right arros spacing.
Can anyone tell me a good way to get around this? I can't figure out what's wrong, since it's working in 99% of the examples.
- 09-17-2005 #2
- Join Date
- Aug 2005
It's using a variable-length font, so number of characters doesn't determine the width. I don't know much about what you're doing, but can you somehow use fixed-width fonts or (better) put them into a table or something?
- 09-17-2005 #3
Thanks. I admittedly know very little about Fonts, so I didn't even think of that.
I changed it to Courier New, and it's working now. Thanks a bunch!!