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 best solutions below
Related Questions in JAVAFX
- JAVAFX error incompatible types: FXMLLoader cannot be converted to node
- How to resolve browser crash issue in JavaFX?
- JavaFX can't play mp3 files
- JavaFX 8 Load external FXML
- All my JavaFX TextFields have lines in them
- Javafx TableView with custom row color using CSS
- Java for Mobile and Desktop Development
- Create Dialogs with Default Images in JavaFX (Info/Warning/Error)
- In javaFx is it possible to make rounded corner of a Rectangle except right-bottom?
- using javafx 8 (java 8 install) How to extend Label.setTooltip Display time to 20secs (while mouse is inside Tooltip)
- javaFX : How to periodically load information from db and show it on a Label?
- How to enable right click option in JavaFX Pane?
- Using ReactFX to resize stage when nodes become invisible?
- How to change collapse and expand icon for a particular treeview in javafx?
- is it possible to set a javaFX Pane origin to bottom-left?
Related Questions in JAVAFX-8
- JavaFX 8 Load external FXML
- How to replace a scene component with a button click inJavaFX
- Using ReactFX to resize stage when nodes become invisible?
- Black Screen - Default Gluon Project
- create and display multiple windows simultaneously using javaFX
- Bind the result of list.contains() method
- JavaFX- Don't scale image for stage icon?
- How to load own font from CSS file into JavaFX application (I'm using now JDK 8u45)
- Where can I find the JavaFX 8 source code for skin classes?
- How do I set the background color of an anchorpane with CSS in Java FX
- JavaFX TextArea get caret position from coordinate
- Can''t get JavaScript to work in WebView
- JavaFX WebView can't load certain sites
- JavaFX ScrollPane - Check which components are displayed
- JavaFX 8 Progress Bar Update from Calculation Script Class
Related Questions in JAVAFX-CSS
- How to pass JavaFX variable into CSS style?
- Hide row in JavaFX Tableview using FX-CSS?
- JavaFX Mnemonic Parsing Creates Extra Space
- JavaFX CSS how do I blend Text color to appear as white when a progress bar overlaps it?
- Best Approach for Managing CSS Stylesheets and Style Classes in a JavaFX Application
- Why does JavaFX Node have wrong sizes in initialize method after css is applied?
- e(fx)clipse css auto completion isn't working and unknown properties
- JavaFX: How to change the color of text in TextArea corresponding to the selectRange
- JavaFX css grid inconsistent
- What's the difference between -fx-text-fill and -fx-text-inner-color in JavaFX CSS?
- how to add same background color for all pane in javafx?
- How create Indent for letters in button. JavaFX
- Can't use a CSS located inside a JAR file in an JavaFX FXML scene
- Cannot add CSS classes to my JavaFX Label
- Styling JFoenix Tabpane
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)
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?
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.