Graphics object won't draw the arrow chars from CharSet IBM437

I'm overriding a JPanel and trying to draw text with Graphics.drawChars. I can print the same exact char to the console right after it's drawn by drawChars and it correctly prints as the arrow. It has the same behavior for all 4 arrows, chars 24 to 27. I create the original string like this:
new String(Array[Byte](32, 24, 25, 26, 27, 32), "IBM437")
new String(Array[Byte](32, 24, 25, 26, 27, 32), "IBM437")
And that string also prints fine to the console. Thanks
16 Replies
JavaBot
JavaBot6mo ago
This post has been reserved for your question.
Hey @adamfh! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
reiwa
reiwa6mo ago
this is likely due to the fact that the Font in the Graphics context you're using does not have glyphs for the arrow characters you're trying to print. have you made sure to choose a font that supports IBM437? if your console is able to display them, try that font first. I assume it will be the same font as your IDE uses. having said that, if you copy the arrows from the console into your ide, do they display? if so you can check you IDEs font and use that in you JPanel to see if that fixes the issue...
adamfh
adamfhOP6mo ago
I don't use an IDE really. I switched to unicode. I am using Monospaced for the font family. 'Consolas' is what my console uses, and that doesn't seem to work. They print directly in the console. I can't copy them from the JPanel. Thanks for the suggestions. I guess I'll stick with Unicode for now.
JavaBot
JavaBot6mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
reiwa
reiwa6mo ago
i'm sorry my suggestion didn't work but just out of curiosity how are you coding in Java and creating a JFrame if not in an IDE?
adamfh
adamfhOP6mo ago
with code, in sublime 3
reiwa
reiwa6mo ago
ahh, and you're running it from the terminal! gotcha
adamfh
adamfhOP6mo ago
Im doing scala and running it from the sbt prompt
reiwa
reiwa6mo ago
i mean you could still try copying them from the terminal into sublime. ah never mind then ahha good luck 🙂
adamfh
adamfhOP6mo ago
mm ill try that That did work, except the left arrow doesn't print on the terminal.
reiwa
reiwa6mo ago
if you haven't changed the default Sublime faont, it'll either be monospace, Consolas or Menlo-Regular. you can find out in Preferences → Settings—User ah so it does seem that the font being used in your JFrame does not support IBM437
adamfh
adamfhOP6mo ago
ill just use unicode, it';s working now. i don't need to recreate this thing using actual IBM437 anyway
reiwa
reiwa6mo ago
ah all the better then, have fun!
adamfh
adamfhOP6mo ago
thanks
JavaBot
JavaBot6mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
JavaBot
JavaBot6mo ago
Post Closed
This post has been closed by <@876309130879598592>.

Did you find this page helpful?