Java Terminal Color Output colorizeBackground(String str, String color)

Here you can find the source of colorizeBackground(String str, String color)

Description

Creates a string with the given backgroundcolor.

License

Open Source License

Parameter

Parameter Description
str String to be colorized.
color Constant defined color (see constants).

Return

String with internal markup-sequences.

Declaration

public static String colorizeBackground(String str, String color) 

Method Source Code

//package com.java2s;
/*/*from   w w  w .  j  a v a 2s  .  c o m*/
 * @(#)ColorHelper.java
 *
 * Copyright 2003 by EkoLiving Pty Ltd.  All Rights Reserved.
 *
 * This software is the proprietary information of EkoLiving Pty Ltd.
 * Use is subject to license terms.
 */

public class Main {
    /** 
     *   Defines the internal marker string 
     * for style/color markups.
     */
    public static final String INTERNAL_MARKER = "\001";
    /** 
     * Defines the markup representation of the graphics rendition 
      * reset.<br> 
     * It will reset all set colors and styles.
     */
    public static final String RESET_ALL = "a";

    /**
     * Creates a string with the given backgroundcolor.
     *
     * @param str String to be colorized.
     * @param color Constant defined color (see constants).
     *     
     * @return String with internal markup-sequences. 
     */
    public static String colorizeBackground(String str, String color) {
        return INTERNAL_MARKER + color.toLowerCase() + str + INTERNAL_MARKER + RESET_ALL;
    }
}

Related

  1. colorise(final char alt, final String message)
  2. colorize(String color, String str)
  3. colorize(String original)
  4. colorize(String string)
  5. colorizeBackground(String str, String color)
  6. colorizeBackground(String str, String color, boolean autoff)
  7. colorizeSequence(String cigar, String seq)
  8. colorizeText(String str, String color)
  9. colorizeText(String str, String color)