728x90
반응형
SMALL
  • Eclipse에서는 플러그인 필요

       install new software : https://www.mihai-nita.net/eclipse

 

My Eclipse Plugins & Java tools — Internationalization Cookbook

This is an Eclipse update page It is intended for Eclipse to install / update my plugins. There is no point in opening it in your browser. Sorry, yes, it was a real page before GitHub killed the “downloads” feature and I had to shuffle things around. T

www.mihai-nita.net

 

  • 많은 양의 데이터가 화면에 출력되며 중요 데이터를 강조하고 싶을 때
  • 내 프로그램은 내 자존심
  • 글자 색상을 지정하는 방법
  • 색을 바꾸고 싶은 구간 앞뒤에 이스케이프 시퀀스(Escape Sequence)를 따른 예약 문자를 붙어서 사용

//arj 압축 lha 압축풀기 zip

 

(1)기본 8색

'\033[색상코드m' + 문장 + '\033[0m'

색상코드 : 30~37 일반 8색, 90~97 밝은일반8색

40~47 배경-일반8색, 100~107 배경-밝은 일반 8색

 

(2)확장 256색

글자색 : '\033[38;5;색상코드m' + 문장 + '\033[0m'

배경색 : '\033[48;5;색상코드m' + 문장 + '\033[0m'

//구글에서 265color를 입력하면 색이 나옴

 

(3)True color(256X256X256) - RED, GREEN, BLUE

글자색 : '\033[38;2;색상코드m' + 문장 + '\033[0m'

배경색 : '\033[48;2;색상코드m' + 문장 + '\033[0m'

색상코드 : R;G;B 0xFF 255

 

 

package Myutil;

public class Colors {
public static String RED = "\\033[31m";
public static String GREEN = "\\033[32m";
public static String YELLOW = "\\033[33m";
public static String BLUE = "\\033[34m";
public static String MAGENTA = "\\033[35m";
public static String CYAN = "\\033[36m";
public static String WHITE = "\\033[37m";
public static String BLACK = "\\033[30m";

public static String REDBG = "\\\\033[101m";
public static String GREENBG = "\\\\033[102m";

public static String END = "\\\\033[0m";

public static void main(String[] args) {
//  TODO Auto-generated method stub
		System.out.println(RED + "RED" + END);
		//결과값 RED
		System.out.println(REDBG + "   " + END);
		//결과값 빨강색

}

}
package Day03;

import Myutil.Colors;

public class ColorTest {

	public static void main(String[] args) {
	//  TODO Auto-generated method stub
	//Colors cl = new Colors();
	//원래라면 이렇게 써야하지만, static를 썼다면 객체를 이렇게 만들지 않아도 됨
	System.out.println(Colors.RED + "Color Test" + Colors.END);
	//결과값 Color Test
	//Colors cl = new Colors();
	//cl = 5; 자바에서는 에러가 나지만, 파이썬에서는 가능함

	//int color =100;

	// basic 8 color

	for(int color=100; color<108; color++) {
		System.out.print("\\\\033[" + color + "m" + "   " +Colors.END);
	}

}

}
package Day03;

import Myutil.Colors;

public class ColorTest {	

	public static void main(String[] args) {
	//  TODO Auto-generated method stub
	//Colors cl = new Colors();
	//원래라면 이렇게 써야하지만, static를 썼다면 객체를 이렇게 만들지 않아도 됨
	System.out.println(Colors.RED + "Color Test" + Colors.END);
	//결과값 Color Test
	//Colors cl = new Colors();
	//cl = 5; 자바에서는 에러가 나지만, 파이썬에서는 가능함

	//int color =100;

	// basic 8 color

	for(int color=100; color<108; color++) {
		System.out.print("\\\\033[" + color + "m" + "   " +Colors.END);
	}

	System.out.println();

	//extended 256 color

	for(int color=0; color<256; color++) {
		System.out.print("\\\\033[48;5;" + color +"m"+ " ");

	}

	System.out.println(Colors.END);

	// true Color
	String[] str = new String[4];
	for(int color=128; color<256; color++) {
		str[0] +="\\\\033[48;2;" + color + ";0;0" + "m" + " ";
	}

}

}
컬러테스트
package Day03;

import Myutil.Colors;
import java.util.Random;

public class ColorTest {

	public static void main(String[] args) {
	//  TODO Auto-generated method stub
	//Colors cl = new Colors();
	//원래라면 이렇게 써야하지만, static를 썼다면 객체를 이렇게 만들지 않아도 됨
	System.out.println(Colors.RED + "Color Test" + Colors.END);
	//결과값 Color Test
	//Colors cl = new Colors();
	//cl = 5; 자바에서는 에러가 나지만, 파이썬에서는 가능함

	//int color =100;

	// basic 8 color

	for(int color=100; color<108; color++) {
		System.out.print("\\\\033[" + color + "m" + "   " +Colors.END);
	}

	System.out.println();

	//extended 256 color

	for(int color=0; color<256; color++) {
		System.out.print("\\\\033[48;5;" + color +"m"+ " ");

	}

	System.out.println(Colors.END);

	// true Color
	String[] str = {"","","",""};  //new String[4]; null이 붙어서 나옴
	for(int color=128; color<256; color++) {
		str[0] +="\\\\033[48;2;" + color + ";0;0" + "m" + " ";
		str[1] +="\\\\033[48;2;" + "0;" + color + ";0" + "m" + " ";
		str[2] +="\\\\033[48;2;" +  ";0;0"+ color + "m" + " ";
		str[3] +="\\\\033[48;2;" +  color + ";" + color + ";" + color + "m" + " ";
	}
	System.out.println(str[0]);
	System.out.println(str[1]);
	System.out.println(str[2]);
	System.out.println(str[3]);

}

public static void p(String title) {
	System.out.println("******************");
	Random rd = new Random();
	int color = rd.nextInt(0,256);
	System.out.print("\\\\033[38;5;" + color + "m" + title);
}

}

 

\\는 두개씩 인데 자꾸 4개로 불어나와요....

노션에서는 안그렇는데 추후 수정 필요!!

728x90
반응형
LIST

'개발 > JAVA' 카테고리의 다른 글

클래스 심화  (0) 2023.01.09
함수(function)  (0) 2023.01.09
배열 (Array)  (0) 2023.01.09
제어문(Control Statement)  (0) 2023.01.09
Random (임의의 수를 얻는 도구)  (0) 2023.01.09

+ Recent posts