How to create a box around text in Java. Inside windows cmd.exe

In summary, the person is asking for help in creating a solid box around text in Java that will be displayed in Windows cmd.exe. They specify that only System.out.print("X"); and System.out.println("X"); can be used and the box must not use symbols like - or _. They also mention that the box can use int X, double X, char X, String X, and boolean X. They request a step-by-step explanation and mention that they are a beginner. They are reminded to show their own attempts if this is a homework assignment.
  • #1
RockHopper
1
0
How can I make a box around text in Java which will appear in Windows cmd.exe?

Only using System.out.print("X"); and System.out.println("X"); . It MUST be a solid box and not use symbols like - or _ .

It can also use int X , double X, char X, String X, and boolean X.



Please explain it step by step. I'm a complete noob. :-)
 
Technology news on Phys.org
  • #2
RockHopper said:
How can I make a box around text in Java which will appear in Windows cmd.exe?

Only using System.out.print("X"); and System.out.println("X"); . It MUST be a solid box and not use symbols like - or _ .

It can also use int X , double X, char X, String X, and boolean X.

Please explain it step by step. I'm a complete noob. :-)

Is this a homework assignment? If so, you need to show what you've tried before we can give any help. See the rules here - https://www.physicsforums.com/showthread.php?t=414380 - especially the section titled Homework Help.
 

1. How do I create a box around text in Java?

To create a box around text in Java, you can use the Graphics class and its drawRect() method. This method takes in the coordinates and dimensions of the box and draws a rectangle around the specified area.

2. Can I create a box around text inside windows cmd.exe?

Yes, you can create a box around text inside windows cmd.exe by using the "chcp" command to change the character encoding to UTF-8 and then using the "chcp" command again to change it back to the original encoding. This will allow you to use Unicode characters to create the box around the text.

3. How can I customize the appearance of the box in Java?

You can customize the appearance of the box in Java by using the setStroke() method of the Graphics2D class. This method allows you to specify the color, thickness, and style of the box's border. You can also use the setPaint() method to add a fill color to the box.

4. Is it possible to create a box around multiple lines of text in Java?

Yes, it is possible to create a box around multiple lines of text in Java. You can use the drawString() method of the Graphics class to draw each line of text individually and then use the getFontMetrics() method to determine the dimensions of the text. With this information, you can then draw a rectangle around the entire block of text.

5. How can I create a box around text using only HTML and CSS?

To create a box around text using only HTML and CSS, you can use the <div> tag to create a container and then use CSS properties like border, padding, and background-color to style the box. You can also use CSS pseudo-elements like ::before or ::after to add a border around the text itself.

Similar threads

  • Programming and Computer Science
Replies
1
Views
7K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
26
Views
6K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
3
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Programming and Computer Science
Replies
4
Views
2K
Back
Top