Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to ceate a console window...

 
Juhan Voolaid
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I want to create a console winddow (panel) to my program. It is just a small panel where some kind of info is displayed like in console when u System.out.println() something. At first i thought that i make a JPanel and fill it with black colour and drawString() the text i want there to be displayed. But my problem is:
If string="one line \n and another line"
when i drawString(string); the text appear on single line.

How could i make new line in drawString() function?
Or what other ways should i use in this situation? And ofcourse is there a way to put (real)console inside a panel?
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
real console: No. will not work.
drawString allways writes a single line and needs coordinates, as far as I know, which may lead to complex calculations.
What's about using a JTextArea?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic