I have been looking at a Swing app that has some special characters in it. The compiler warned me when I tried to run it in Netbeans that they might not display properly. Then the characters in question were displayed as boxes. This seems like an obvious error to do with encoding so hopefully someone can tell me how to fix it. Thanks.
The first thing you need to find out is: What encoding is the file which contains those characters in? (I'm guessing it's source code but you didn't specify that.)
It's likely you will say "How should I know?" Well, if you are looking at the file with some kind of text editor then that text editor will be using a suitable encoding, since you are seeing them correctly. So either the text editor was told what encoding to use, or it's using a default encoding.
Next, it looks like Netbeans is using a different encoding, since it tells you upfront that it doesn't recognize them as Unicode characters and it displays them as something which the font doesn't recognize as characters. So telling Netbeans to use the correct encoding (as identified from the first step) would fix that problem.
Actually... I just realized that when you said "the characters in question were displayed as boxes" you might have meant that Netbeans displayed them as boxes. I had sort of assumed that you meant that running the code resulted in them being displayed as boxes.
(Characters are displayed as boxes because the font used to display them doesn't have a glyph for them.)
So my suggestion now is when you see the characters appearing in Netbeans as boxes instead of ä, ö and å, you should simply correct them to whichever of ä, ö and å they are supposed to be.
When you see squares where you're expecting characters, that's an indication that the font that's displaying that text doesn't have graphics (glyphs) defined for those characters.
When you're developing an app with an IDE, you often have more than one font involved and some of them may support the characters of interest and some may not.
In particular, the font that the IDE uses for its text editors may be completely unrelated to the font(s) used by the application.
That's fine, but it's hard to edit text when it doesn't render, so you might have to adjust your IDE preferences so that it edits using a more useful font.
Likewise, it's not going to win you any friends if your GUI app doesn't use fonts that are compatible with the character set you're expecting it to handle.
Note that fonts generally don't match exactly. Fonts are selected from the computer's font collection based on a "best-match" algorithm. So if a system doesn't have Helvetica installed, it may pick Arial as the nearest approximation. Just make sure that the systems of interest have compatible glyph sets.
Bjoke: A "Bully Joke". A Statement or action made with malicious intent - unless challenged. At which point it magically transforms into "I was just funnin'" or "What's the matter, can't take a joke?"