# JFXHighlighter in Processing

**URL:** <https://discourse.processing.org/t/jfxhighlighter-in-processing/48070>\
**Category:** Coding Questions\
**Created:** [March 10, 2026, 9:08pm UTC](https://discourse.processing.org/t/jfxhighlighter-in-processing/48070 "2026-03-10T21:08:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![swp791](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/swp791/32/21287_2.png) [@swp791](https://discourse.processing.org/u/swp791)\
**Post date:** [March 10, 2026, 9:08pm UTC](https://discourse.processing.org/t/jfxhighlighter-in-processing/48070/1 "2026-03-10T21:08:24Z")

</div>

Hello.

Has anyone used the JFoenix library with Processing. I am trying to make a text highlighter in a JavaFX TextArea. Since JavaFX doesn’t have one I tried using the [JFoenix library](https://github.com/sshahine/JFoenix) without much success. After some research it seems that JFoenix and JavaFX API are incompatible?

This is the error i get.

java.lang.reflect.InaccessibleObjectException: Unable to make private com.sun.javafx.scene.text.TextLayout javafx.scene.text.Text.getTextLayout() accessible: module javafx.graphics does not “opens javafx.scene.text” to unnamed module @18be83e4

```processing
import processing.javafx.*;

import com.jfoenix.utils.*;
import com.jfoenix.controls.*;
import com.jfoenix.utils.JFXHighlighter;
import com.jfoenix.utils.JFXNodeUtils;
import com.jfoenix.utils.JFXUtilities;
import com.jfoenix.controls.JFXTextArea;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXTextField;
import java.util.*;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.scene.canvas.Canvas;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.Pane;
import javafx.application.Application;
import javafx.scene.layout.VBox;
import javafx.scene.text.TextFlow;

Pane pane;
Canvas canvas;
StackPane root;
Stage primaryStage;
  
JFXHighlighter highlighter = new JFXHighlighter();

void setup() {
  size(700, 600, FX2D);
  background(#FFFFFF);
  surface.setTitle("JavaFX C0ntrols");
  canvas = (Canvas)surface.getNative();
  root = (StackPane)canvas.getParent();
  pane = new Pane();
  root.getChildren().add(pane);
  JFXTextArea textArea = new JFXTextArea();
  textArea.setPromptText("Type some text here...");
  textArea.setPrefRowCount(6);

  // Search field
  JFXTextField searchField = new JFXTextField();
  searchField.setPromptText("Enter text to highlight");
  println("DEBUG");
  // Highlight button
  JFXButton highlightBtn = new JFXButton("Highlight");
  highlightBtn.setOnAction(e -> {
    String query = searchField.getText();
    if (query != null && !query.isEmpty()) {
      highlighter.clear(); // Clear previous highlights
      highlighter.highlight(textArea, query);
    }
  }
  );

  // Clear button
  JFXButton clearBtn = new JFXButton("Clear Highlights");
  clearBtn.setOnAction(e -> highlighter.clear());

  VBox vBoxMain = new VBox(10, textArea, searchField, highlightBtn, clearBtn);
  vBoxMain.setStyle("-fx-padding: 15;");

  pane.getChildren().add(vBoxMain);
}

```

Regards, Mike.

Link to the project folder.

[Full Project](https://drive.proton.me/urls/6DJWBHHAN4#cBKRqaUm3qBr)

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [March 11, 2026, 3:27am UTC](https://discourse.processing.org/t/jfxhighlighter-in-processing/48070/2 "2026-03-11T03:27:34Z")

</div>

> [@swp791](#):
>
> I am trying to make a text highlighter in a JavaFX TextArea.

Did you mean JFXTextArea?

On my system (MacOS) the problem seems to be with JFXTextField. The following fails:

```processing
import com.jfoenix.controls.JFXTextField;
import javafx.scene.canvas.Canvas;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.Pane;

void setup() {
  size(350, 200, FX2D);
  Canvas canvas = (Canvas)surface.getNative();
  StackPane root = (StackPane)canvas.getParent();
  Pane pane = new Pane();

  JFXTextField textField = new JFXTextField();
  println(textField);

  pane.getChildren().add(textField);
  root.getChildren().add(pane);
}

```

The following will run provided I use the latest .jar file. However, it fails if the searchField is added to VBox.

```processing
import com.jfoenix.utils.*;
import com.jfoenix.controls.*;

import javafx.scene.canvas.Canvas;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.layout.Pane;

Pane pane;
Canvas canvas;
StackPane root;
JFXHighlighter highlighter;

void setup() {
  size(700, 600, FX2D);
  background(#FFFFFF);
  surface.setTitle("JFXHighlighter Demo");
  canvas = (Canvas)surface.getNative();
  root = (StackPane)canvas.getParent();
  pane = new Pane();

  highlighter = new JFXHighlighter();
  println("highlighter",highlighter);
  JFXTextArea textArea = new JFXTextArea();
  println("textArea =",textArea);
  textArea.setPromptText("Type some text here...");
  textArea.setPrefRowCount(6);  
  // Search field
  JFXTextField searchField = new JFXTextField();
  println("searchField = ",searchField);
  searchField.setPromptText("Enter text to highlight");
  // Highlight button  
  JFXButton highlightBtn = new JFXButton("Highlight");
  println("highlightBtn =",highlightBtn);  
  highlightBtn.setOnAction(e -> {
    println("highlight btn hit.");
    String query = searchField.getText();
    if (query != null && !query.isEmpty()) {
      highlighter.clear(); // Clear previous highlights
      highlighter.highlight(textArea, query);
    }
  }
  );
  // Clear button
  JFXButton clearBtn = new JFXButton("Clear Highlights");
  clearBtn.setOnAction(e -> {
    highlighter.clear();
    println("clear btn hit.");
  });

  VBox vBoxMain = new VBox(textArea, highlightBtn, clearBtn); //searchField,
  vBoxMain.setStyle("-fx-padding: 15;");
  pane.getChildren().add(vBoxMain); 
  root.getChildren().add(pane);
}

```

The fix is supposedly to add:

`–add-opens java.base/java.lang.reflect=ALL-UNNAMED`

which may go in a gradle file. I tried adding it to Preferences.txt but it didn’t seem to help.

**Output:**

 ![JFX](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/7/9/791c16b36abac62db46dfe0c01244f931845f86b.png)

---

<div class="post-metadata">

**Author:** ![swp791](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/swp791/32/21287_2.png) [@swp791](https://discourse.processing.org/u/swp791)\
**Post date:** [March 11, 2026, 4:09pm UTC](https://discourse.processing.org/t/jfxhighlighter-in-processing/48070/3 "2026-03-11T16:09:52Z")

</div>

Thanks @svan .

> [@svan](#):
>
> –add-opens java.base/java.lang.reflect=ALL-UNNAMED

adding it like this to preferences.txt fixed the issue.

run.options=-–add-opens=java.base/java.lang.reflect=ALL-UNNAMED

There were five other opens/exports that had to be added as well.

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [March 11, 2026, 7:34pm UTC](https://discourse.processing.org/t/jfxhighlighter-in-processing/48070/4 "2026-03-11T19:34:55Z")

</div>

> [@swp791](#):
>
> run.options=-–add-opens=java.base/java.lang.reflect=ALL-UNNAMED

I’m glad that you got it to working. What operating system are you using? I can’t get it to run on my macOS system; Processing keeps overwriting my Preferences.txt file and deleting the above line that I added. I did have the Processing.app closed when I made the changes. Any way that you could update your above link to a runnable demo? What are the other additions that you had to make to Preferences.txt and did you add the lines at the top of the file or someplace else? Thanks for making us aware of this interface.

---

<div class="post-metadata">

**Author:** ![swp791](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/swp791/32/21287_2.png) [@swp791](https://discourse.processing.org/u/swp791)\
**Post date:** [March 11, 2026, 7:48pm UTC](https://discourse.processing.org/t/jfxhighlighter-in-processing/48070/5 "2026-03-11T19:48:49Z")

</div>

> [@svan](#):
>
> Processing keeps overwriting my Preferences.txt file and deleting the above line that I added.

I noticed if you enter incorrect data Processing reverts the changes. It also printed an error in the console saying which line was incorrect.

> [@svan](#):
>
> What operating system are you using?

Windows10.

> [@svan](#):
>
> I did have the Processing.app closed when I made the changes

You do have to restart IDE for changes to take effect.

[Preference File](https://drive.proton.me/urls/VM9J42MFB0#WqHMAzIwA9BE)

see line 87.

[Project](https://drive.proton.me/urls/8DY3QY20XR#v97lozxIu6AN)

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [March 11, 2026, 8:43pm UTC](https://discourse.processing.org/t/jfxhighlighter-in-processing/48070/6 "2026-03-11T20:43:02Z")

</div>

> [@swp791](#):
>
> adding it like this to preferences.txt fixed the issue.
> 
> run.options=-–add-opens=java.base/java.lang.reflect=ALL-UNNAMED
> 
> There were five other opens/exports that had to be added as well.

Hello @swp791,

It took interest!

Environment:

- Windows 10
- Processing 4.5.2
- _jfoenix-9.0.10.jar_ was added to sketch (drag and drop).

Your code ran without error adding this to _Preferences_:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/9/5951c613f9c8ead340323dbdb729139599309837.png)

```auto
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=javafx.graphics/javafx.scene.text=ALL-UNNAMED --add-opens=javafx.graphics/javafx.scene=ALL-UNNAMED --add-opens=javafx.controls/javafx.scene.control.skin=ALL-UNNAMED --add-exports=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED

```

ChatGPT was used to analyze the initial errors and direct me to a solution.

ChatGPT Reference:

> **[jdk-migration-guide.pdf](https://docs.oracle.com/en/java/javase/17/migrate/jdk-migration-guide.pdf)**
>
> 405.04 KB

`:)`

---

<div class="post-metadata">

**Author:** ![swp791](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/swp791/32/21287_2.png) [@swp791](https://discourse.processing.org/u/swp791)\
**Post date:** [March 11, 2026, 11:07pm UTC](https://discourse.processing.org/t/jfxhighlighter-in-processing/48070/7 "2026-03-11T23:07:27Z")

</div>

Yes! That’s about it. Its good to know i can edit those preferences from the IDE now.
