• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

have a problem rendering a text in JOptionpane + JTextArea

Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am trying to render a text like this

JOptionPane.showMessageDialog(parent,getcomponent(errormsg), erromsg ,type , imageicon);
where component is a JScrollpane having a JTextArea within it.

There is a problem with this message rendering in the JTextArea.
say if the error message is some thing like this:-

cmd not found
prompt\>dir1 filename

In the JTextArea it is rendered as follows:-

cmd not found
prompt\>dir1 filename

Can some one please tell me what might be the problem. I tried using the JEditorPane and JTextPane instead of JTextArea. But the problem persists.

While debugging when i watch the string it is absolutely correct but when it is not rendering properly as i see in the string.

I even tried changing the fonts and font size as well. But all in vain.

Thanks a lot
Posts: 21758
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Next time UseCodeTags if you want to preserve the whitespace at the start.

Try setting the font of the text area to something monospaced like Courier New.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!