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]
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 code in a GUI application that I'm writing:
My idea here is to line up things into two columns of data. This works almost universally, except in 2 examples:Code:if(currentCode.length() > 11) tab_string = "\t"; else tab_string = "\t\t";
http://soori.netfirms.com/example/stringlength1.png
http://soori.netfirms.com/example/stringlength2.png
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 #2Linux Enthusiast
- Join Date
- Aug 2005
- Location
- Hell
- Posts
- 514
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
Yay!
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!!


Reply With Quote
