aspose file tools*
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Write to Jtextpane until it wraps." Watch "Write to Jtextpane until it wraps." New topic
Author

Write to Jtextpane until it wraps.

Carl John
Ranch Hand

Joined: Jun 14, 2010
Posts: 47

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 ?


CJohn
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10384
    
    8

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

[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: 2183
    
    7
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Write to Jtextpane until it wraps.