• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JEditorPane and images via the IMG tag

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic