Issue
Good afternoon. I'm having some problems with JavaFX, basically I create my Labels by code (I'm using IntelliJ IDE):
Calls from the Card object (Object containing the Label):
vibrationCard = new Card("METRICA", "Eixos de vibração", "");
fftCard = new Card("METRICA", "FFT", "");
Object Card (Object that contains the Label)
public Card(String topLabel, String title, String bottomLabel){
cardTitleLabel = new Label(title);
cardTitleLabel.setFont(new Font(14.0));
//Code remainder
cardStruct.getChildren().addAll(
cardTopLabel,
cardTitleHeaderHBox,
separator,
contentAnchorPane,
cardBottomLabel
);
getChildren().addAll(cardStruct);
}
The problem is, my labels have strange characters where they should be accented letters:
I've already set the IDE to UTF-8 and I've also tried converting the formatting of the string to see if I could fix it, but it didn't work.
Solution
Solution:
You must make sure that
- The Java source files in your editor are saved using UTF-8
- The Compiler does read them using UTF-8
If you use Maven, add this to your pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
If you use Gradle, add this to your build.gradle:
tasks.withType(JavaCompile) {options.encoding = 'UTF-8'}
Additional notes:
Converting from and back UTF-8 is tricky sometimes. As last resort, delete the file, rewrite its content with copy Paste and rewrite the Strings MANUALLY WITH YOUR KEYBOARD NOT WITH COPY PASTE, because the characters theirself can be in the wrong format. This can happen too by copy pasting characters from the internet or from third Party documents into a String.
Answered By - David Weber
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.