Questions tagged [swing-highlighter]

Questions about javax.swing.text.Highlighter.

27 questions
11
votes
4 answers

How to change highlighting color in Java Swing TextArea? And also, change the beginning of text corresponding to the highlighting location

Problem 1: BY using defaulthighlighter, I can make the focused lines change to blue. Now I want to change it to other colors. Do anyone know how to change this parameter? --- solved Problem 2: pos is the beginning index of my substring which I want…
AnneS
  • 1,393
  • 3
  • 13
  • 19
5
votes
1 answer

How to highlight a single word in a JTextArea

I want to read in text the user inputs and then highlight a specific word and return it to the user. I am able to read in the text and give it back to the user, but I cant figure out how to highlight a single word. How can I highlight a single word…
Jonny Forney
  • 1,458
  • 3
  • 13
  • 15
5
votes
4 answers

Changing color of selected text in jTextPane

I am creating a text editor using a JTextPane that allows the user to change the color of selected text. But when the user selects the text, then chooses the option to change the color (say, to red) the text does not appear as red until the text is…
smith8ar
  • 71
  • 1
  • 7
5
votes
2 answers

jTextArea stops showing highlighting on text after losing focus

When my jTextArea is in focus it allows text highlighting, but it doesn't show the text selection when it loses focus. Is it possible to continue displaying the text highlighting even if the user moves focus to another component on the related…
4
votes
3 answers

Removing Highlight from specific word - Java

I want to build one sample to remove highlight from words that matches the filter of my app. Therefore I was basing myself on the sample below: public void removeHighlights(JTextComponent jTextArea) { Highlighter hilite =…
Victor R. Oliveira
  • 2,434
  • 5
  • 36
  • 66
3
votes
1 answer

Highlighter vs. StyledDocument of Java Swing for changing the color of text in a JTextPane

I've been using setCharacterAttributes of StyledDocument to change the colors of specific words or sections in a JTextPane. But then I noticed some answers here where they use a Highlighter (typically DefaultHighlighter) to do the same thing. What…
Gigatron
  • 1,905
  • 5
  • 20
  • 27
3
votes
1 answer

Refresh/Update highlighter in JTable when changing search values

how can I refresh the highlighter in my JTable after changing the search value in the JTextField? It works fine with the JTextArea under the JTextfield, but I the JTable won't refresh the highlighter. Any Suggestions?? This is my Code: import…
Ramses
  • 602
  • 2
  • 6
  • 25
3
votes
1 answer

Random erronous highlighted resulted in JTextPane (Arabic)

I'm trying to search and highlight words in my JTextPane. It works wonderfully with words that don't have a lot of results so far but when I try to search for a word that has a lot instances, sometimes, the highlighter highlights the result way off,…
user2191986
  • 33
  • 1
  • 4
2
votes
2 answers

How to get highlighted text in a jtextarea

I have a jtextarea with some texts. I use java highligher to highlight some texts on that jtextarea. I want to print the content of that textarea to another textarea with the highlighted texts. Is that possible? Or is there any way of getting only…
Nuwan
  • 360
  • 3
  • 8
  • 20
2
votes
1 answer

Change text selection type in a JTextArea

In most of the text editors, I have seen that when text is selected, all the line changes the color to the selection color. But in JTextArea, during the selection only the text color is changed during selection. How can I achieve the above mentioned…
Muhammad Omer
  • 503
  • 1
  • 8
  • 14
2
votes
0 answers

ColorHighlighter on JXTreeTable - Change selection color if predicate is true

I'm using an JXTreeTable with several ColorHighlighters to change the background color of the rows that include a specific value. If a row is selected, the color will change to SelectionBackground. Is it possible to change the selection background…
mjohannes
  • 21
  • 3
2
votes
2 answers

JTextPane highlighting issue

The last days I have been trying to implement a highlighting feature in a small text editor. For some reason I get a strange result: The given example should highlight each "dolor" - the first occurences are correctly found and highlighted but the…
Markus
  • 1,085
  • 1
  • 16
  • 37
2
votes
2 answers

Highlight a text on specific line in JTextArea using Start and End Offset

Am having a method that highlights all the occurrences of a word in a Text Area. Is there any way to use start and end offset to highlight the word only in that line. My current codes. public static void highlight(JTextComponent textComp, String…
Ms_Joe
  • 160
  • 2
  • 7
  • 16
2
votes
1 answer

highlight some words in the jeditorpane in java swing

I am working on a swing application in which i have to show HTML files in JEditorPane. I have to highlight some text e.g. For all occurrences of boy . I am using the following code but it is highlighting the whole text of JEditorPane : try { …
adesh
  • 1,067
  • 3
  • 18
  • 28
1
vote
1 answer

Highlighting a selected line in JTextArea

I've been searching for a way to highlight the selected line in JTextArea. There are many post on how to highlight text in a JTextArea, but it only goes as far as the letters go. I want to be able to highlight the whole line (much like how the…
Zero
  • 29
  • 10
1
2