Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Write to Jtextpane until it wraps.

 
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
Saloon Keeper
Posts: 11092
13
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: 2612
9
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic