Michał Skóra
Michał Skóra

Reputation: 371

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.

Upvotes: 0

Views: 640

Answers (1)

MeBigFatGuy
MeBigFatGuy

Reputation: 28588

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);

Upvotes: 1

Related Questions