Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes JEditorPane and images via the IMG tag 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 "JEditorPane and images via the IMG tag" Watch "JEditorPane and images via the IMG tag" New topic
Author

JEditorPane and images via the IMG tag

Kerry Shetline
Greenhorn

Joined: Feb 09, 2006
Posts: 14
I'm trying to use the IMG tag to add images to an HTML JEditorPane, and I've run into some questions and issues.

1) I can easily grab an image when I set the SRC attribute of an IMG tag to a full URL, but I want to use a local resource from my application's JAR file instead, not something hosted out on some web site somewhere? I'd rather not have to use a 'file://' URL that's going to have to be different for applet vs. stand-alone application implementations, that's not going to have to be different when I'm running in my IDE (with no JAR file built yet) vs. or running a fully built and deployed application.

2) What can I do, if anything, to include images created at run time, which don't exist in any form other than a run-time BufferedImage? Can I intercept URL processing somehow (overriding JEditorPane.getStream() didn't work) so I can control the image loading process?

3) What's up with how the ALIGN attribute of an IMG is interpreted? An alignment of 'top' looks like it aligns the top of an image with the baseline of the surrounding text instead of the top of the text line (completely useless!), 'middle' looks like it's doing what it's supposed to do (but it isn't a very useful alignment), and 'bottom' makes the bottom of my images ride about one or two pixels above the text baseline instead of right on the baseline.

The most useful alignment for me would be for the middle of an image to be aligned with the middle of the text ascent, not including padding for diacritical marks -- but even regular web browsers and the standard HTML/CSS specs don't support that particular alignment, much to my dismay.

At any rate, can the ALIGN behavior be overridden? I suspect that such a thing is probably buried too deeply in the Swing implementation to change without rewriting half of the Swing code, unfortunately.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JEditorPane and images via the IMG tag
 
Similar Threads
DIV shrinks to fit its content
Struts 2 Tiles
Aligning HTML text/images in JEditorPane
nbsp in .xsl?
text alignment for Jtextfield