I am planning to get the range of selected text from TextArea and change the font color of the selectRange. My TextArea is initialized as a part of FXML file. I'm able to get the selectRange by using textArea.getSelection(), I would like to color the text in the range returned by above method. Please suggest me how to do it.
JavaFX: How to change the color of text in TextArea corresponding to the selectRange
1.9k views Asked by Karthik SP At
1
There are 1 answers
Related Questions in JAVAFX
- Function for making the code wait in javafx
- JavaFX build generating a blank gui with primary view and secondary view buttons
- JavaFX SwingNode instantiation fails with exception
- I want to understand modularity in java. When compiling my app I have a ResolutionException
- Importing Jython into a JavaFX application
- gluon attach audio doesn't play any sound on android
- Using javaFx, how to distinguish between return-key and enter-key on the numpad?
- Displaying a Hashmap in a TableView in JavaFX
- HBox doesn't fill parent GridPane when rotated by 90 degrees
- Run java program
- Setting up MongoDB with JavaFX in Intellij, MongoDB external Jar files throwing errors
- JavaFX not support GPU hardware decoding?
- JavaFX resize ImageView in center of BorderPane
- In Javafx how to access object of a component which is under an overridden method? Problem related with TableView
- How to style rounded corners of a TextArea in JavaFX
Related Questions in JAVAFX-8
- How could I make a slider like this? Could this even be executed as a slider, or do I need another kind of node for this?
- Javafx textfield expanding to width of popup window
- JavaFX. Blocking user actions
- How to populate a JavaFX Textfield upon Redirection Using a Controller
- Why does Apache NetBeans Null Pointer Exception give me an error in my Java FXML project?
- How to remove blue border from TableColumn in JavaFX during reordering
- How to properly inherit an FXML annotated attribute for having it available in a subclass?
- How to fix JavaFX alignment problem when grouping elements?
- How to Change the Custom Color Lable text color using javafx css
- Creating PDFs in a custom javafx application
- why are the messages only being printed on client side of the GUI?
- Updating TableView from another FXML/Controller
- Get values from the ListView and display on a label in JavaFX
- Figma with JavaFX and custom components
- Javafx showing folder icons when I run it
Related Questions in JAVAFX-CSS
- Best Approach for Managing CSS Stylesheets and Style Classes in a JavaFX Application
- JavaFX choicebox [combobox] Prompt Text Color
- JavaFX css, loaded from a fxml file, doesn't seem to be loading an image
- Inline JavaFX CSS has troubles with properties
- Removing the blue color effect when DatePicker is clicked
- JavaFX : style defined in fxml file (via SceneBuilder) cannot be overridden by the CSS file, how do I do this?
- How to fix out-of-place 'expected RBRACE' error when parsing CSS with jfx?
- How do I correctly use variables in JavaFX CSS Stylesheets?
- JavaFX: Give Line Chart Series of multiple tables different colors
- Can't use a CSS located inside a JAR file in an JavaFX FXML scene
- How create Indent for letters in button. JavaFX
- JavaFX CSS - How to curve a border radius outwards?
- How to use Partial Border with CSS in javaFX?
- I'm trying to change the background color of textarea in scenebuilder, but the outline color is changing
- Why aren't my CSS borders showing up in JavaFX gui?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Firstly I would recommend to go with any rich text controls(RichTextFX) for your requirement. But if you are very specific with using TextArea, check the below approach.
The approach that I am providing may not be a correct solution or it may not suit to your exact requirement. But it can help you to think in that direction.
This is based on the idea provided(by @en_Knight) in Highlighting Strings in JavaFX TextArea. I recommend to first go thorugh this OP and then check my below implementation.
I had created a custom TextArea control, which works on the same principle provided in the mentioned OP. i.e, blending the nodes to get the desired effects. You can check different blend effects by changing the value of the combobox in the demo. I assume for your requirement you may need BlendMode.ADD
The highlight still remains while you are selecting the text.