How to set the color of a text selection?

Post a reply

Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review
   

Expand view Topic review: How to set the color of a text selection?

Re: How to set the color of a text selection?

Post by Endogen » Wed Jan 08, 2014 7:22 pm

Thanks for the help, worked. :)

Re: How to set the color of a text selection?

Post by robert » Wed Jan 08, 2014 1:27 pm

By default RSTA still colors tokens with their syntax highlighting colors when selected. To turn this off, call:

java code:

textArea.setUseSelectedTextColor(true);


Then, you can fetch the "right' color for the selection background and selected text from the UIManager. Alternatively, you can use the "default-alt.xml" theme shipped with the RSTA source to automatically load a theme that sets up the selection to use the L&F defaults. Or write your own theme and load it. More information about that here.

How to set the color of a text selection?

Post by Endogen » Sat Jan 04, 2014 5:22 pm

I want to change the default color of selected text. I tried
Code: Select all
setSelectedTextColor(Color.black);
but that didn't change the color. How can i achieve that?
Example:

java code:

public class TextEditorDemo extends JFrame {

public TextEditorDemo() {

JPanel cp = new JPanel(new BorderLayout());

RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);

textArea.setSelectedTextColor(Color.black); // Doesnt work??

RTextScrollPane sp = new RTextScrollPane(textArea);
cp.add(sp);

setContentPane(cp);
setTitle("Text Editor Demo");
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setLocationRelativeTo(null);

}

public static void main(String[] args) {
// Start all Swing applications on the EDT.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new TextEditorDemo().setVisible(true);
}
});
}
}

Top

cron