About 18,800,000 results
Open links in new tab
  1. java - How to set a string's color - Stack Overflow

    Jan 16, 2016 · Does anyone know how I would set the color of a string that will be printed using System.out? This is the code I currently have: System.out.println ("TEXT THAT NEEDS TO BE A DIFFERENT COLOR.");

  2. java - How to change the color of string - Stack Overflow

    Aug 1, 2012 · you have to set the Color of the Text in TextView. Not the String color. It is not valid. textView.setTextColor(Color.RED); or Change your String to Html like this, String s= "<font color=#00aeef>"+"Right Answers:" + " " + String.valueOf(nRightAnswers)+"</font>"; and textView.setText(Html.fromHtml(s));

  3. change color of a string in java - Stack Overflow

    Oct 13, 2011 · With the Jansi library, you should be able to colour your text as you wish, for example : AnsiConsole.systemInstall(); AnsiConsole.out.println("\033[32mHowdy"); The code above prints the Howdy in green, in the console, although …

  4. How to Print Colored Text in Java Console? - GeeksforGeeks

    Aug 12, 2021 · So here we can use ANSI_BLACK in place of ANSI_COLORNAME to print the text in Black color. The second part is to write the text which we want to print in that color. The ANSI_RESET code turns off all ANSI attributes set so far, which should return the console to its defaults. Below is the ANSI color code table :

  5. How to Change Text Color in a String Using Multiple Colors in Java?

    In Java, changing the text color of a string to multiple colors involves using text components that support styled text, such as `JTextPane`. This allows you to manipulate portions of the text …

  6. Set Font and Color of Text in JTextPane Using Styles

    Learn how to set the font and color of specific text in a JTextPane using styles in Java with this comprehensive guide.

  7. How to Convert a String to a Color in Java - CodingTechRoom

    Converting a string to a color in Java typically involves interpreting the string format—commonly hex, RGB, or color names—and utilizing Java's built-in classes like `Color`. This response …

  8. java - Using a string to set a color [SOLVED] | DaniWeb

    I think you will have to set up a HashMap to link the Strings to actual Colors, eg HashMap<String, Color> map = new HashMap<String, Color> (); map.put ("Red", Color.RED); map.put ("Green", Color.GREEN); // etc ... String colorName = "Green"; g.setColor (map.get (colorName)); Or you could use Refection to access the Color constants by name.

  9. Java: how do I change the color of a string? - Stack Overflow

    Oct 4, 2010 · You have to give more context, like James Black said. If you're talking about the console, check the bottom of my my post. If you're using Swing and a JLabel, for example: JLabel title = new JLabel("Want a Raise?", JLabel.CENTER); title.setForeground(Color.white); Source: http://www.leepoint.net/notes-java/GUI/components/10labels/jlabel.html

  10. Change font colors in Java console output - Non valet

    Apr 13, 2021 · To change terminal colors, you just need to add an ANSI code before your string. One of the most practical way to do that is to create a class that can store static strings with that code, that can be easily imported to your projects. Your strings can have obvious names for better code readability. Let's have a look.

Refresh