Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Swing / AWT / SWT and the fly likes Write to Jtextpane until it wraps. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Write to Jtextpane until it wraps." Watch "Write to Jtextpane until it wraps." New topic

Write to Jtextpane until it wraps.

Carl John
Ranch Hand

Joined: Jun 14, 2010
Posts: 47


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

Joined: Jul 26, 2007
Posts: 10172

Check out
You can probably get your desired result "write hyphen character" by modifying doc.insertString(offs, "\r", attrs);
Disclaimer: I haven't tried it myself

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Carl John
Ranch Hand

Joined: Jun 14, 2010
Posts: 47

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

Joined: Jun 13, 2009
Posts: 2155
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.
subject: Write to Jtextpane until it wraps.
Similar Threads
Wrap mode in JTextpane
Failed SCWCD four times
Insert html
set wrap around off in JTextPane