How would one make one word of out put bold. I am making rock paper scissors using threads and I want to make the choice of either rock, paper, or scissors bold. So for example the output of the program would be "Player 1 chose Rock. How can I do this?

3 Years
Discussion Span
Last Post by JamesCherrill

so if this is a console programme u can use "\033" this special character String s = "Player 1 chose \033[1mRock";actually this "Rock" part may can give gray look but if it is the issu change the order like String s = "\033[1mPlayer 1 chose \033[0mRock";

FYI "[1m" means start to bold "[0" means terminate the bold effect

but if this is a GUI based programme use java FONT API
label.setFont(new Font("default", Font.BOLD, 16));

Edited by noelDuino


Can I use this with system.out.println() So for example i would have

System.out.println("Player " + id+ " chose \033[1m" + choice + "\033[0m")

A word of caution - not all console devices and/or OS's support ANSI escape sequences, so if this works for you that's great, but don't assume it's portable or will work on someone else's computer. In general your chances are much better under Linux than under Windows.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.