In my swing UI, there is JTextArea component named "textarea_webpage", I want to mark some sentence in the textarea as marked using program just as user selecting them using mouse.
------------------------------------------------------------Code Below-------------------------------------------------
textarea_webpage.setSelectionColor(Color.black);
textarea_webpage.setSelectedTextColor(Color.white);
textarea_webpage.setSelectedTextColor(Color.white);
textarea_webpage.select(urlItem.getStart(),urlItem.getEnd()); // the urlItem is self-defined object to store positon information of certain sentences
----------------------------------------------------------------------------------------------------------------------------
Every time the code is executed, there is nothing take place in my textarea.
After goolge for the answer in the net.
I found that I forgot the code
textarea_webpage.getCaret().setSelectionVisible(true);
There are so many tricks in Swing designing, I'm just a beginner.
Pay more attention.