base64 image into JTextPane

Posted by Nicolas on Stack Overflow See other posts from Stack Overflow or by Nicolas
Published on 2010-04-29T08:30:42Z Indexed on 2010/04/29 9:37 UTC
Read the original article Hit count: 557

Filed under:
|
|
|

Is it possible to display a base64 encrypted image into a JTextPane ?

Here my code

JTextPane jTextPane = new JTextPane();

javax.swing.text.html.HTMLEditorKit eKit = new javax.swing.text.html.HTMLEditorKit();
jTextPane.setEditorKit(eKit);

jTextPane.setContentType("text/html");

// my base64 image, used then in the img tag in the html...
String img64="data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7";

jTextPane.setText(html);

© Stack Overflow or respective owner

Related posts about jtextpane

  • base64 image into JTextPane

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Is it possible to display a base64 encrypted image into a JTextPane ? Here my code JTextPane jTextPane = new JTextPane(); javax.swing.text.html.HTMLEditorKit eKit = new javax.swing.text.html.HTMLEditorKit(); jTextPane.setEditorKit(eKit); jTextPane.setContentType("text/html"); // my base64 image… >>> More

  • Background Image in JTextPane

    as seen on Stack Overflow - Search for 'Stack Overflow'
    How do I set a background image to a JTextPane - some sort of a watermark. I tried this option - creating a child class of JTextPane and use the paint method to draw the image. But then the text is displayed "below" the image than above. Is there any "standard" or "well known" way to do this? (BTW… >>> More

  • Java JTextPane Save

    as seen on Stack Overflow - Search for 'Stack Overflow'
    i was trying to do some simple text formatting using JEditorPane but then as knowledge grew i found JTextPane easier to implement and more robust. my query is how do i save the formatted text in JTextPane to file? it should be RTF or HTML or other.. as this file is not opened by the application again… >>> More

  • Java Simple Chat Box

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I am trying to create a very simple chat window that simply has the ability to display some text, which i add to from time to time. However I get the following run time error when attempting to append text to the window: java.lang.ClassCastException: javax.swing.JViewport cannot be cast to javax… >>> More

  • Changing content of HTMLDocument displayed in a JTextPane

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I'm displaying some tables as HTML code (rendered by a Freemarker template) with a JTextPane. I also have some HTML links in this HTML output which can be used to interact with the values of the table (For example "Delete a row" and stuff like this). Currently I always recreate the whole HTML output… >>> More

Related posts about base64