This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes StyledDocuments Image Alignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "StyledDocuments Image Alignment" Watch "StyledDocuments Image Alignment" New topic

StyledDocuments Image Alignment

Charles Kent

Joined: Aug 07, 2008
Posts: 1
Hey everybody, I've got two questions. I've been working on a program which uses a jtextpane+styled document. The document has both text (multiple styles), and one .gif picture.

1)The document looks much like a page of text with the image at the top left. The problem? I want the image at the top right while keeping the text left-aligned. I've tried setCharacterAttributes(), setParagaphAttributes(), and insertString() with right-aligned styleconstants, alas it has not worked. The character attribute call did something funky and put in the image, but at the bottom of the document and right aligned. I input the text via a String[] so I can add the appropriate styles to differnt portions of the document.

2) Is there a way to save a styleddocument file to rtf format with which it includes the picture? I've only been able save the text from the document. Would breaking the document up in 2 and trying to use and ImageIO for one and FileWriter for the text work, trying of course to put it all into the selected name from JFileChooser.

Thanks in advance, any and all help would be appreciated
I agree. Here's the link:
subject: StyledDocuments Image Alignment
It's not a secret anymore!