This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "StyledDocuments Image Alignment" Watch "StyledDocuments Image Alignment" New topic
Author

StyledDocuments Image Alignment

Charles Kent
Greenhorn

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: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: StyledDocuments Image Alignment
 
Similar Threads
Graphics and word documents
JEditorPane and images via the IMG tag
Java rotating image (AffineTransform) image getting cut off at parts?
Zoom In Function help!!!!!
Having a hard time figuring out how to accomplish this in Swing