Search code examples
javaimageswingjeditorpane

Display image from database (MySQL via hibernate) in JEditorPane?


i have to display image stored in my database, or e.g. created in program memory, in JEditorPane. Is there any way to do it? Thanks for reply.

I forgot tell that my JEditorPane is a WYSIWYG html editor. Html editor mean that, i can edit text like in OpenOffice, but this is still desctop application.


Solution

  • Assuming that the image is stored in a BLOB, get an input stream from the blob and pass it to

    BufferedImage image = ImageIO.read(InputStream is);
    

    Then have your pane's

    paintComponent(Graphics g)
    

    do among other things

    g.drawImage(image, transform, observer);