Q:

How to change the selected word color with POI XWPF

How can i change the selected word font color?
I want to create a function for this, but my level is so basic with this api...
This is my pseudo cod:
 public String setTextColor(String word){
     String coloredWord = null;
     /**
     * setColor method here
     */
    return coloredWord;
}

So, this function have to return the colored word. 
Please help, if you can :)

A:

You need to set the Run Property. This works similarly to Rich Text Strings in the Excel API, but is a bit different.
// p is your paragraph object
XWPFRun r = p.createRun();
r.setColor("ff0000");
r.setText("This text is red");
r = p.createRun();
r.setText(" but this text is black");

All text in a given run has the same formatting properties. Any time those properties need to change, you need to add a new run to the paragraph.

