Hello,
I have a question about JTextArea colors. When i set the color to blue and then write something on the JTextArea (JTextArea.append) and then set it back to black everything will be black. How can i solve that? Like in Notepad++ or Eclipse when you write keywords in a JTextArea (where you write your code) only some words change color.
This is my code:
// All the imports public class whatever extends JFrame { JTextArea a = new JTextArea(); public whatever() { super("Title"); add(a); a.setForeground(Color.RED); a.append("Hello there"); a.setForeground(Color.BLACK); } } public static void main(String[] args) { whatever object = new whatever(); object.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); object.setSize(400, 500); object.setVisible(true); }