4

How can I make bold the text in eclipse? To be more clear I give an example: we write in syntax

System.out.print("Name: ");
String name = in.nextLine();

When we run the program the user should input the name: NAME: David I whant to make David bold and change the size

Arezu Tehrani
  • 73
  • 1
  • 1
  • 5
  • 1
    Possible of duplicate of http://stackoverflow.com/questions/6286701/an-eclipse-console-view-that-respects-ansi-color-codes, or http://stackoverflow.com/questions/233790/colorize-logs-in-eclipse-console – eboix Dec 14 '11 at 19:23
  • 1
    *"..in eclipse?"* Exactly the same way you would do it in Netbeans, or IntelliJ, or notepad.. Or to put that another way, this has absolutely nothing to do with your IDE. – Andrew Thompson Dec 14 '11 at 19:34
  • 1
    @eboix +1 for the second link – Cody S Dec 14 '11 at 20:12

2 Answers2

4

@Tomasz is completely correct. However, if you want to set a bold font on "most" terminals, you can write out

      private final String setPlainText = "\033[0;0m";
      private final String setBoldText = "\033[0;1m";

e.g.

      System.out.println (setPlainText + "Prompt>" + setBoldText);

This isn't quite universal, but it works for most all terminals in popular use. To get any fancier, you'll want to look at something like What's a good Java, curses-like, library for terminal applications? or switch to building a GUI, e.g. perhaps using Swing.

Community
  • 1
  • 1
BRPocock
  • 13,638
  • 3
  • 31
  • 50
1

Actually You can't change size of the font in text terminal. There is no such an information sent to terminal by Your application. (Only plain text is sent through the stream) This is possible and easy in graphic applications, made in Java and managed by Java API. Before You begin with these I advise You to start from some easy books or tutorials about Java essentials.

Essentials of the Java Programming Language, Part 1

By the way this is the code than can make Your task (excluding change of font size or font style)

    import java.io.*;
    public class Main {
    public static void main(String[] args) throws IOException {
    BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
    String name = br.readLine();
    System.out.print("Name: "+name);
}

    }

Only one thing possible to change using eclipse console is the font color of the output stream and error stream. (Right click on the console screen and preferences)

Bhesh Gurung
  • 50,430
  • 22
  • 93
  • 142
Tomasz
  • 19
  • 4