JavaFX and Unicode source files

The JavaFX compiler supports unicode source files, just as Java compiler does. To use them you need to

  • make sure the source does not include the three-byte byte-order-mark
  • call javafxc with the -encoding parameter
JavaFX and Unicode Text

JavaFX and Unicode Text

javafxc -encoding UTF-8 Chinese.fx
javafx Chinese

And now for the example

import javafx.application.*;
import javafx.scene.Font;
import javafx.scene.text.Text;
import javafx.scene.paint.Color;

Frame {
  title: "JavaFX Unicode Example"
  width: 400 height: 300
  stage: Stage
  {
    content: Text {
      x: 20 y: 150
      fill: Color.ORANGE
      content: "我也会说华文"
      font: Font { size: 50 }
    };
    fill: Color.BLACK;
  }
  visible: true
}

This is a prerecorded message

Bookmark and Share

You should follow me on twitter here

Comments are closed.