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?

Recommended Answers

All 4 Replies

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));

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.