JavaFX: set empty message for TableView

myTableView.setPlaceholder(new Label("My table is empty."));

JavaFX: how to use ListProperty?

when adding element to ListProperty, like below:
ListProperty<String> members = new SimpleListProperty<String>();
it throws UnsupportedOperationException
  at java.util.AbstractList.add(
  at java.util.AbstractList.add(
  at java.util.AbstractCollection.addAll(
  at javafx.beans.binding.ListExpression.addAll(
The problem was that the ListProperty was not properly initialized. To make it work, see the following code
ObservableList<String> observableList = FXCollections.observableArrayList(new ArrayList<String>());
ListProperty<String> members = new SimpleListProperty<Priority>(observableList);

see also


  • 王: King
  • 后: Queen
  • 象: Bishop
  • 马: Knight
  • 车: Rook
  • 卒: Pawn


  1. 安装Bluestacks安卓模拟器
  2. 下载《电视家直播》破解版,用Bluestacks打开,会自动安装。
  3. 启动Bluestacks运行《电视家直播》,一定要调成软解码。否则不停出现源失效错误。

See also

JavaFX: Add CSS to TreeTableView


JavaFX TreeTableView set font weight of a TreeTableColumn

Create a css file:
column.setStyle("-fx-font-weight: bold;");

Include javascript on

Including raw github url of javascript in your web page will not work. You need to use some web site with CDN services to forward the request to github.
see this

Make Papaya Javascript DICOM viewer work in JavaFX WebView

When loading Papaya Javascript DICOM/NIFTI Viewer in a JavaFX WebView, it failed with error message:
Papaya requires Safari version 6 or higher.
So I checked WebKit version of JavaFX 8 using the following code:
WebView web = new WebView();
it shows the JavaFX 8 WebKit UserAgent information:
Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.19 (KHTML, like Gecko) JavaFX/8.0 Safari/538.19
According to Safari version history, Safari 6.0 is based on WebKit 536.25, while Webkit in JavaFX 8 is 538.19. WebKit in JavaFX 8 is above Safari 6.0. The problem is the browser detection in Papaya could not detect the version. So the work around is to modify the Papaya source code to accept JavaFX 8 WebKit agent.
  1. Check out Papaya js:
    git clone
  2. Edit src/js/utilities/platform-utils.js, insert the following code:
    papaya.utilities.PlatformUtils.checkForBrowserCompatibility = function () {
        if (navigator.userAgent.indexOf('JavaFX')>=0) {
            return null;
       ... ... ...
  3. Download and build Papaya-builder, then install it into Papaya/lib/:
    git clone
    cd Papaya-Builder
    cp build/papaya-builder.jar ../Papaya/lib/
  4. Build Papaya:
    cd Papaya
    ls build/

Java: Open a url with default web browser

Open a web page with default web browser (from Java code):
try {
    java.awt.Desktop.getDesktop().browse(new URI(""));
} catch (Throwable e) {

SIM Unlock Telstra ZTE MF60 WIFI modem

  1. Install ZTE MF60 Windows Driver on your Windows PC
  2. Install latest DC Unlocker
  3. Insert a non Telstra SIM, powered it on, and connect the ZTE MF60 WIFI modem to your Windows PC via USB
  4. Open DC-Unlocker as Administrator, select "ZTE Modems" then click "Detect" to detect the device
  5. Close DC Unlocker
  6. Run DCCrap to unlock the device (This will retain the IMEI & MAC address).

See also

JavaFX: load css from file

  • load from relative path:
     // the java class is in the same directory as the .css file.
    String css = getClass().getResource("MyApp.css").toExternalForm();
  • load from absolute path:
    // the .css file is stored under <ROOT>/css/ directory.
    String css = getClass().getResource("css/MyApp.css").toExternalForm(); 

JavaFX: Show grid lines of TreeTableView

  • Save the following to resources/MyApp.css:
    .tree-table-row-cell {
        -fx-background-color: -fx-table-cell-border-color, -fx-control-inner-background;
        -fx-background-insets: 0, 0 0 1 0;
        -fx-padding: 0.0em;
        -fx-text-fill: -fx-text-inner-color;
    .tree-table-row-cell:selected {
        -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-focus-color;
        -fx-background-insets: 0, 1, 2;
    .tree-table-row-cell:odd {
        -fx-background-color: -fx-table-cell-border-color, derive(-fx-control-inner-background,-5%);
        -fx-background-insets: 0, 0 0 1 0;
    .tree-table-row-cell:selected:odd {
        -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-focus-color;
        -fx-background-insets: 0, 1, 2;
  • In your Java class, add the css to a scene.
    String css = getClass().getResource("/resources/MyApp.css").toExternalForm();

Java: Convert image to png format

  • Make sure you have JAI & ImageIO plugins installed. Recommend to use standlone/independent jai-imageio-core from github.
  • The example code:
    • import java.awt.image.BufferedImage;
      import javax.imageio.ImageIO;
      public static void main(String[] args) {
        // read a tiff image
        BufferedImage bufferedImage = File("c:/tmp/1.tif"));
        // write back to another file in png format
        ImageIO.write(bufferedImage, "png", new File("c:/tmp/1.png"));

SSH access to Github from multiple accounts

  • Generate SSH Keys:
    ssh-keygen  -t rsa -b 4096 -C "" -f ~/.ssh/id_rsa_personal
    ssh-keygen  -t rsa -b 4096 -C "" -f ~/.ssh/id_rsa_work
    The two commands above generate two key pairs: id_rsa_personal/, id_rsa_work/
  • Add SSH Keys to your github accounts.
    • Add to your personal github account:
      • Login to your github
      • Go to Settings -> Add SSH Keys
      • Copy of the content of to the key field
      • Click Add Key
    • Add to your github account for work:
      • Login to your github
      • Go to Settings -> Add SSH Keys
      • Copy of the content of to the key field
      • Click Add Key
  • Create a file: ~/.ssh/config and add:
    • Host personal
         User git
         IdentityFile ~/.ssh/id_rsa_personal
      Host work
         User git
         IdentityFile ~/.ssh/id_rsa_work
  • Update stored identities:
    • ssh-add -D
      ssh-add id_rsa_personal
      ssh-add id_rsa_work
  • Test
    • ssh -T personal
      Hi githubPersonal! You've successfully authenticated, but GitHub does not provide shell access.
      $ ssh -T work
      Hi githubWork! You've successfully authenticated, but GitHub does not provide shell access.

Github: Use Access Token to authenticate over HTTPS

  • Login to Github
  • If you have not enabled Two-factor authentication, you need to enable it:
    • Go to "Settings" -> "Security"
  • Generate Personal Access Tokens:
    • Go to "Settings" -> "Personal Access Tokens"
  • Click "Generate new token" at the top right corner.
  • Remember/Copy the token.
  • Insert the token to your repository url:
  • Now you can push to the repository without typing username & password.