Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Write to Jtextpane until it wraps.  RSS feed

 
Carl John
Ranch Hand
Posts: 47
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I'm writing string value to JTextpane like (heading of contents)

Order# OrderDate Product Description Rate Qty Specs.

I just want to write hyphen character below to the headings, to the entire line of the textpane until it wraps..

Any suggestions ?

 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out http://java-sl.com/wrap.html
You can probably get your desired result "write hyphen character" by modifying doc.insertString(offs, "\r", attrs);
Disclaimer: I haven't tried it myself
 
Carl John
Ranch Hand
Posts: 47
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It just prints only single character. not till the end of line..

I want to print hyphen till the end of line.
 
Rob Camick
Ranch Hand
Posts: 2754
12
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would recommend using a JTable for something like this since it is designed to display row/column data.

If you are going to use a JTextPane then you should use a "monospaced font". Then each character takes up the same space so it is easier to align your columns.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!